You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by Zhuo Jia Dai <zh...@gmail.com> on 2020/05/01 05:01:06 UTC

How to include arrow and parquet in another project's CMakeLists.txt

Hi all,

I am trying to write a Julia parquet writer by leveraging the C++ arrow
library. I can build arrow and arrow/parquet and can write out a parquet
file successfully. The next part I need to do is to use the [CxxWrap.jl](
https://github.com/JuliaInterop/CxxWrap.jl) Julia package to call the C++
functions I wrote. However, CxxWrap.jl underlying JlCxx library only has
build examples in CMake, so I am having issues modifying the CMakeLists.txt
to add the arrow and arrow/parquet dependencies.

This is the error I get when I try to run their CMake process, so I should
be able to add something to the CMakeLists.txt file to tell i where to the
find the parquet and arrow libraries right? I am so new to C++ that I am at
lost on how to do this. I have include the CMakeLIst.txt file at the very
end! Thanks for any help and for helping me make a Julia parquet write a
reality.


```
[ 50%] Building CXX object CMakeFiles/testlib.dir/testlib.cpp.o
/home/xiaodai/git/ParquetWriter.jl/test-include-julia/testlib.cpp:26:10:
fatal error: parquet/arrow/writer.h: No such file or directory
 #include "parquet/arrow/writer.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/testlib.dir/build.make:62: recipe for target
'CMakeFiles/testlib.dir/testlib.cpp.o' failed
make[2]: *** [CMakeFiles/testlib.dir/testlib.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testlib.dir/all'
failed
make[1]: *** [CMakeFiles/testlib.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
```

The CMakeLists.txt I am using now

```
project(TestLib)

cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

find_package(JlCxx)
get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION)
get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}")

message(STATUS "Found JlCxx at ${JlCxx_location}")

add_library(testlib SHARED testlib.cpp)

target_link_libraries(testlib JlCxx::cxxwrap_julia)

install(TARGETS
  testlib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib)
```

Regards



-- 
ZJ

zhuojia.dai@gmail.com

Re: How to include arrow and parquet in another project's CMakeLists.txt

Posted by Sutou Kouhei <ko...@clear-code.com>.
Hi,

Adding find_package(Parquet REQUIRED) to CMakeLists.txt and
parquet_shared to target_link_libraries() will work:

---
project(TestLib)

cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

find_package(JlCxx)
get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION)
get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}")

message(STATUS "Found JlCxx at ${JlCxx_location}")

# Added:
find_package(Parquet REQUIRED)

add_library(testlib SHARED testlib.cpp)

# Added: parquet_shared
target_link_libraries(testlib JlCxx::cxxwrap_julia parquet_shared)

install(TARGETS
  testlib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION lib)
---


You may need to add
-DCMAKE_MODULE_PATH=/PATH/TO/FindParquet.cmake option to
your cmake command line if you don't install Apache Parquet
by our Linux packages.


Thanks,
--
kou

In <CA...@mail.gmail.com>
  "How to include arrow and parquet in another project's CMakeLists.txt" on Fri, 1 May 2020 15:01:06 +1000,
  Zhuo Jia Dai <zh...@gmail.com> wrote:

> Hi all,
> 
> I am trying to write a Julia parquet writer by leveraging the C++ arrow
> library. I can build arrow and arrow/parquet and can write out a parquet
> file successfully. The next part I need to do is to use the [CxxWrap.jl](
> https://github.com/JuliaInterop/CxxWrap.jl) Julia package to call the C++
> functions I wrote. However, CxxWrap.jl underlying JlCxx library only has
> build examples in CMake, so I am having issues modifying the CMakeLists.txt
> to add the arrow and arrow/parquet dependencies.
> 
> This is the error I get when I try to run their CMake process, so I should
> be able to add something to the CMakeLists.txt file to tell i where to the
> find the parquet and arrow libraries right? I am so new to C++ that I am at
> lost on how to do this. I have include the CMakeLIst.txt file at the very
> end! Thanks for any help and for helping me make a Julia parquet write a
> reality.
> 
> 
> ```
> [ 50%] Building CXX object CMakeFiles/testlib.dir/testlib.cpp.o
> /home/xiaodai/git/ParquetWriter.jl/test-include-julia/testlib.cpp:26:10:
> fatal error: parquet/arrow/writer.h: No such file or directory
>  #include "parquet/arrow/writer.h"
>           ^~~~~~~~~~~~~~~~~~~~~~~~
> compilation terminated.
> CMakeFiles/testlib.dir/build.make:62: recipe for target
> 'CMakeFiles/testlib.dir/testlib.cpp.o' failed
> make[2]: *** [CMakeFiles/testlib.dir/testlib.cpp.o] Error 1
> CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testlib.dir/all'
> failed
> make[1]: *** [CMakeFiles/testlib.dir/all] Error 2
> Makefile:129: recipe for target 'all' failed
> make: *** [all] Error 2
> ```
> 
> The CMakeLists.txt I am using now
> 
> ```
> project(TestLib)
> 
> cmake_minimum_required(VERSION 2.8.12)
> set(CMAKE_MACOSX_RPATH 1)
> set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
> 
> find_package(JlCxx)
> get_target_property(JlCxx_location JlCxx::cxxwrap_julia LOCATION)
> get_filename_component(JlCxx_location ${JlCxx_location} DIRECTORY)
> set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}")
> 
> message(STATUS "Found JlCxx at ${JlCxx_location}")
> 
> add_library(testlib SHARED testlib.cpp)
> 
> target_link_libraries(testlib JlCxx::cxxwrap_julia)
> 
> install(TARGETS
>   testlib
> LIBRARY DESTINATION lib
> ARCHIVE DESTINATION lib
> RUNTIME DESTINATION lib)
> ```
> 
> Regards
> 
> 
> 
> -- 
> ZJ
> 
> zhuojia.dai@gmail.com