that worked, very appreciate it.

------------------ Original ------------------
From:                                                                           
                                             "user"                             
                                                       <[email protected]&gt;;
Date:&nbsp;Tue, May 18, 2021 09:45 PM
To:&nbsp;"user"<[email protected]&gt;;

Subject:&nbsp;Re: why I can't use `arrow::py::import_pyarrow()' in c++



You have to initialize the Python interpreter when using it embedded in a C++ 
application. &nbsp;

On Tue, May 18, 2021 at 8:36 AM auderson <[email protected]&gt; wrote:

Thanks for your reply!


After I linked arrow_python_shared, calling import_pyarrow now caused a 
SEGFAULT.


I've posted my code on stackoverflow&nbsp;c++ - arrow::py::import_pyarrow() 
cause a SEGMENTATION FAULT - Stack Overflow


I'm pretty new to C++, and maybe there are protocols I did't follow?
------------------&nbsp;Original&nbsp;------------------
From:                                                                           
                                             "user"                             
                                                       <[email protected]&gt;;
Date:&nbsp;Tue, May 18, 2021 09:15 PM
To:&nbsp;"user"<[email protected]&gt;;

Subject:&nbsp;Re: why I can't use `arrow::py::import_pyarrow()' in c++




You have to link libarrow_python (arrow_python_shared) where this symbol is 
found.&nbsp;

On Tue, May 18, 2021 at 3:09 AM auderson <[email protected]&gt; wrote:

Hi,


I'm using arrow-cpp 4.0.0 installed from conda. I also have pyarrow 4.0.0 
installed.


In my test.cpp file, import_pyarrow() will throw an error: undefined reference 
to `arrow::py::import_pyarrow()'


#mini_example.cpp
#include "mini_example.h"
#include <arrow/python/pyarrow.h&gt;

int main() {
    arrow::py::import_pyarrow();
}

&nbsp;#mini_example.h


#include <arrow/python/pyarrow.h&gt;
int main() {
    arrow::py::import_pyarrow();
}


#CMakeLists.txt


cmake_minimum_required(VERSION 3.10.0)
project(TEST)
set(CMAKE_CXX_STANDARD 17)

list(APPEND CMAKE_PREFIX_PATH "/home/auderson/miniconda3/lib/cmake/arrow")
find_package(Arrow REQUIRED)


include_directories(.
        /home/auderson/miniconda3/include
        /home/auderson/miniconda3/include/python3.8)

add_executable(TEST
        mini_example.cpp
        )

target_link_libraries(${PROJECT_NAME} PRIVATE 
/home/auderson/miniconda3/lib/libpython3.8.so)
target_link_libraries(${PROJECT_NAME} PRIVATE arrow_shared)The full 
output:CMakeFiles/TEST.dir/mini_example.cpp.o: In function `main': 
/tmp/tmp.vmULkzpuYF/mini_example.cpp:9: undefined reference to 
`arrow::py::import_pyarrow()' collect2: error: ld returned 1 exit statusBut 
other functionalities works fine, like create an Array then build a Table from 
them. In fact I'm just stuck at the last step where I have to wrap the table so 
that they can be passed to cython.Can you find where I'm doing wrong? Thanks!
Auderson

Reply via email to