ossia / libossia

A modern C++, cross-environment distributed object model for creative coding and interaction scoring
https://ossia.io
GNU Lesser General Public License v3.0
206 stars 33 forks source link

generate ossiaConfig.cmake file to help including in cmake project #392

Closed avilleret closed 6 years ago

avilleret commented 6 years ago

we need https://github.com/OSSIA/libossia/blob/master/CMake/ossiaConfig.cmake.in cf https://cmake.org/cmake/help/git-master/manual/cmake-packages.7.html#creating-a-package-configuration-file

then we should use find_package(ossia 1.0 REQUIRED) and target_link_libraries(myapp ossia) in Cmake project

jcelerier commented 6 years ago

see also https://github.com/pabloariasal/modern-cmake-sample/blob/master/libjsonutils/CMakeLists.txt#L68

jcelerier commented 6 years ago

done, can be tested with a CMakeLists.txt that looks like this :

cmake_minimum_required(VERSION 3.12)
project(foo CXX)

find_package(ossia)

add_executable(foo main.cpp)
target_link_libraries(foo PRIVATE ossia::ossia)
avilleret commented 6 years ago

I got undefined symbol with the following :

$ mkdir /tmp/libossia
$ cd /tmp/libossia
$ wget https://github.com/OSSIA/libossia/releases/download/v1.0.1/libossia-native-linux_x86_64.tar.gz
$ tar -xf libossia-native-linux_x86_64.tar.gz
$ mkdir /tmp/test
$ cd /tmp/test
$ wget https://raw.githubusercontent.com/OSSIA/libossia/master/Documentation/Tutorial/CPP98/device.cpp
$ cat > CMakeLists.txt <<- "EOF"
cmake_minimum_required(VERSION 3.12)
project(foo CXX)

find_package(ossia)

add_executable(foo device.cpp)
target_link_libraries(foo PRIVATE ossia::ossia)
EOF
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_PREFIX_PATH=/tmp/libossia/
-- The CXX compiler identification is GNU 8.2.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Boost version: 1.67.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/antoine/dev/CPP98/build
$ cmake --build  .
Scanning dependencies of target foo
[ 50%] Building CXX object CMakeFiles/foo.dir/device.cpp.o
[100%] Linking CXX executable foo
/usr/bin/ld: CMakeFiles/foo.dir/device.cpp.o: in function `test_callback(void*, opp::value const&)':
device.cpp:(.text+0x87): undefined reference to `opp::value::to_string[abi:cxx11]() const'
/usr/bin/ld: CMakeFiles/foo.dir/device.cpp.o: in function `main':
device.cpp:(.text+0x152): undefined reference to `opp::oscquery_server::oscquery_server(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int)'
/usr/bin/ld: device.cpp:(.text+0x1cc): undefined reference to `opp::node::create_child(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: device.cpp:(.text+0x22d): undefined reference to `opp::node::create_float(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: device.cpp:(.text+0x360): undefined reference to `opp::node::create_child(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: device.cpp:(.text+0x3f1): undefined reference to `opp::node::set_unit(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: device.cpp:(.text+0x478): undefined reference to `opp::oscquery_mirror::oscquery_mirror(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: device.cpp:(.text+0x51c): undefined reference to `opp::node::find_child(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: device.cpp:(.text+0x71c): undefined reference to `opp::node::get_name[abi:cxx11]() const'
/usr/bin/ld: device.cpp:(.text+0x732): undefined reference to `opp::node::remove_child(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld a retourné le statut de sortie 1
make[2]: *** [CMakeFiles/foo.dir/build.make:85: foo] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/foo.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
avilleret commented 6 years ago

hum... I got the same with (from /tmp/test folder)

 c++ device.cpp -I../libossia/include -L../libossia/lib -lossia

so I guess the issue is in libossia.so build by travis...

jcelerier commented 6 years ago

I don't understand, shouldn't the ossia-cpp release be used instead of

wget https://github.com/OSSIA/libossia/releases/download/v1.0.1/libossia-native-linux_x86_64.tar.gz

avilleret commented 6 years ago

libossia-native is build with ossia-cpp support and I got the same with https://github.com/OSSIA/libossia/releases/download/v1.0.1/libossia-cpp-linux_x86_64.tar.gz

I'm gonna test with local build

avilleret commented 6 years ago

it works with a local build, so I'm closing this issue since it does work (but not the travis build)