I want to play sound through opensl. Connected library Linker-> Input-> Library Dependencies - OpenSLES. The linker produces an error - undefined reference to slCreateEngine.
check your target_link_libraries method inside CmakeLists.txt if it has all the necessary libraries included..
target_link_libraries( # Specifies the target library.
native-lib
android
log
OpenSLES)
Related
this is not the first time I meet this error, but [previous solution][1] doesn't make sense.
[100%] Linking CXX executable ../bin/qttest
/usr/bin/x86_64-linux-gnu-ld: CMakeFiles/qttest.dir/src/main.cpp.o:
undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols:
DSO missing from command line collect2: error: ld returned 1 exit
status
here is my cmakelists
cmake_minimum_required(VERSION 2.4.6)
set(OpenCV_DIR "/usr/local/opencv-2.4.9/share/OpenCV")
include_directories("/usr/local/opencv-2.4.9/include")
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
find_package(Qt4 COMPONENTS QtCore QtGui)
find_package(OpenCV 2.4.9 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
rosbuild_init()
rosbuild_genmsg()
find_package(Boost COMPONENTS system REQUIRED)
set(qt_srcs
src/mainwindow.cpp
src/listnerthr.cpp
src/ros_thr.cpp
src/CreatDataBuffer.cpp
src/CreatBuffer.cpp
src/pid_controller.cpp
src/low_pass_filter.cpp
src/plot_publisher.cpp)
set(qt_hdrs
src/mainwindow.h
src/listnerthr.h
src/ros_thr.h
src/CreatDataBuffer.h
src/HelperFunctions.h
src/CreatBuffer.h
src/pid_controller.h
src/low_pass_filter.h
src/plot_publisher.h)
qt4_automoc(${qt_srcs})
QT4_WRAP_CPP(qt_moc_srcs ${qt_hdrs})
QT4_WRAP_UI(uis_h src/mainwindow.ui)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_executable(qttest src/main.cpp
${uis_h} ${qt_srcs} ${qt_moc_srcs})
target_link_libraries(qttest ${QT_LIBRARIES}${Boost_LIBARAIES }${OpenCV_LIBARAIES})
any clues would be appreciated.
I got another problem after changing the cmakelists
*** No rule to make target '/usr/lib/x86_64-linux-gnu/libboost_system.so/usr/lib/x86_64-linux-gnu/libboost_system.so', needed by '../bin/qttest'. Stop. CMakeFiles/Makefile2:425: recipe for target 'CMakeFiles/qttest.dir/all' failed –
You should pass boost libraries to the target_link_libraries command. The smallest change to your file will be as follows:
target_link_libraries(qttest ${QT_LIBRARIES} ${LIBS})
But since you are using find_package for Boost and you do not actually use your LIBS variable anywhere, you should stick with something like this:
find_package(Boost COMPONENTS system REQUIRED)
...
target_link_libraries(qttest ${QT_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES})
And remove LIBS altogether.
I was trying to convert an existed c++ project to CMake. The existed worked well with makefile, and i have converted similar one successfully. but when i try to convert this one, some confusing errors occurred, as below:
18:22:10: Running steps for project encryption...
18:22:10: Starting: "/export/opt/cmake-3.2.2/bin/cmake" --build . --target all
Linking CXX executable dist/Debug_64/GNU-Linux-x86/encryption
CMakeFiles/encryption.dir/encryption.cc.o: In function `main':
/export1/chao/nanos/nano_clean/nano_clean/src/encryption/encryption.cc:33: undefined reference to `stlp_std::cout'
...
/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/stl/_string.c:604: undefined reference to `stlp_std::__stl_throw_out_of_range(char const*)'
...
At first i think it can't find iostream, so i include iostream at /export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/ by using 'INCLUDE_DIRECTORIES', but it did not work. Could you please give me some advices?
My CMakeLists.txt as below:
include_directories(/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport)
include_directories(/export1/chao/nanos/nano_clean/nano_clean/lib/STLport/stlport/h/using)
include_directories(/export1/chao/nanos/nano_clean/nano_clean/lib/boost/1.49.0/boost/tr1/tr1)
link_directories(
../common/dist/${CONF}/GNU-Linux-x86
/export2/chao/nanos/nano_built/lib/tiburonda/dist/include
)
aux_source_directory(. SRC_LIST)
include_directories(../common/include
)
add_executable(encryption ${SRC_LIST})
target_link_libraries(encryption libcommon.a)
According to original makefile, i found this project use source file encryption.cc at ./, header files: encryption.h at ./ and others at ../common/include.
I get a strange linker error when building a project (which uses GStreamer 1.0 and therefore depends on Glib 2.0) with cmake and linking against glib library. Glib is installed using macports, libglib-2.0.0.dylib is present in /opt/local/lib/. FindGLIB successfully finds its header files (compiling works) and also ${GLIB_LIBRARIES} provides the right path to the library.
The error message is
[100%] Linking CXX executable ../bin/presenter
Undefined symbols for architecture x86_64:
"_g_object_set", referenced from:
...
"_g_type_check_instance_cast", referenced from:
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I remove glib from the list completely it's also copmplaining about missing reference to g_print and g_printerr. Is it possible that the linking is done correctly but the functions are just missing for some reason inside the library?
How can I fix it?
Finally found my mistake. When using FindGLIB of the Webkit project, it by default searches only for the main glib library. It's components have to be passed in addition to be found:
find_package(GLIB COMPONENTS gobject REQUIRED)
would find glib itself and save it in ${GLIB_LIBRARIES} and also gobject and save it in ${GLIB_GOBJECT_LIBRARIES} so they can be used in target_link_libraries()
Reminder: Always read the comments in the file headers - they often contain useful information...
# Optionally, the COMPONENTS keyword can be passed to find_package()
# and Glib components can be looked for. Currently, the following
# components can be used, and they define the following variables if
# found:
#
# gio: GLIB_GIO_LIBRARIES
# gobject: GLIB_GOBJECT_LIBRARIES
# gmodule: GLIB_GMODULE_LIBRARIES
# gthread: GLIB_GTHREAD_LIBRARIES
I'm having a bit of trouble getting a rustc compiled staticlib for triple, arm-linux-androideabi, to link up nicely within Android Studio.
Steps taken...
Install Rust via multirust
Build a rustc for Android API v14
Build lib with --target=arm-linux-androideabi
Add to jniLibs/ within Android Studio
Create a little C++ shim for hooks to/from JNI
Build and link (almost)
When building my crate, I get the following output:
note: link against the following native artifacts when linking
against this static library
note: the order and any duplication can be significant on some platforms,
and so may need to be preserved
note: library: c
note: library: m
note: library: dl
note: library: log
note: library: gcc
note: library: c
note: library: m
So naturally, my Android.mk includes these libs when using the staticlib.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hydrogen
LOCAL_SRC_FILES := ../jniLibs/$(TARGET_ARCH_ABI)/libhydrogen.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := hydrogen-android
LOCAL_SRC_FILES := shim.cpp
LOCAL_STATIC_LIBRARIES := hydrogen
LOCAL_LDLIBS := -lc -lm -ldl -llog -lgcc -lc -lm
include $(BUILD_SHARED_LIBRARY)
Building in Android Studio gives me the following output:
:app:buildCppShim
Android NDK: WARNING:/Android.mk:hydrogen: non-system libraries in linker flags: -lgcc -lgccunwind
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi] Compile++ thumb: hydrogen-android <= shim.cpp
[armeabi] SharedLibrary : libhydrogen-android.so
[snipped]function sync::rwlock::StaticRwLock::read::ha5ec9717ccd1ed83Lxp: error: undefined reference to 'pthread_rwlock_rdlock'
[snipped]function sys_common::rwlock::RWLock::read::h7f3d472c79e2e1e2Z1q: error: undefined reference to 'pthread_rwlock_rdlock'
[snipped]function sys_common::rwlock::RWLock::read_unlock::hd7d67e9c5c47b9f5B2q: error: undefined reference to 'pthread_rwlock_unlock'
[snipped]function sync::rwlock::StaticRwLock::try_read::hddd396186cced62f8xp: error: undefined reference to 'pthread_rwlock_tryrdlock'
[snipped]function sys_common::rwlock::RWLock::try_read::ha5aede723e91a3c881q: error: undefined reference to 'pthread_rwlock_tryrdlock'
[snipped]function sync::rwlock::StaticRwLock::write::h787666bb30e75d28Ryp: error: undefined reference to 'pthread_rwlock_wrlock'
[snipped]function sys_common::rwlock::RWLock::write::h0273da9a7ade68c0i2q: error: undefined reference to 'pthread_rwlock_wrlock'
[snipped]function sync..rwlock..RwLockWriteGuard$LT$$LP$$RP$$GT$::drop.34348::h4c8fbe45843b9a01: error: undefined reference to 'pthread_rwlock_unlock'
[snipped]function sync::rwlock::StaticRwLock::try_write::h5d30a7fdd53c86b4ezp: error: undefined reference to 'pthread_rwlock_trywrlock'
[snipped]function sys_common::rwlock::RWLock::try_write::h0ec4bcc0cb460718r2q: error: undefined reference to 'pthread_rwlock_trywrlock'
[snipped]function sync::rwlock::StaticRwLock::destroy::ha1e9f51e62905aedXzp: error: undefined reference to 'pthread_rwlock_destroy'
[snipped]function sys_common::rwlock::RWLock::destroy::h602ce773ff2356e6T2q: error: undefined reference to 'pthread_rwlock_destroy'
[snipped]function sys::rwlock::RWLock::read::h241f5fdff06a76ab00u: error: undefined reference to 'pthread_rwlock_rdlock'
[snipped]function sys::rwlock::RWLock::write::h48034b52e6491ea4h3u: error: undefined reference to 'pthread_rwlock_wrlock'
~/bin/rust/src/compiler-rt/lib/builtins/gcc_personality_v0.c
Error:(206) undefined reference to '_Unwind_GetIP'
Error:(273) undefined reference to '_Unwind_SetGR'
Error:(274) undefined reference to '_Unwind_SetGR'
Error:(275) undefined reference to '_Unwind_SetIP'
pthread errors
I'm not sure why I received the errors about pthread, because I have #include <pthread.h> in my shim, and these functions are defined in Android's pthread.
unwind errors
For this, I've tried including unwind.h in the shim and libgccunwind.a in the Android.mk, but still throws the same errors. I found this thread where a hack-solution was to just declare the prototypes in the shim, but when I do this, I receive the following errors about unwind.h
Error:(231, 3) error: previous declaration 'void _Unwind_SetGR(_Unwind_Context*, int, _Unwind_Word)' here
So, it is able to find their declarations when I declare them, because they conflict, but has no idea where they are if I do not? I'm assuming it has to be something wrong with my linking order, but unsure of how to solve it, because the required libs are linked against after pulling in the rust created lib.
Any help would be greatly appreciated!
Edit 1
Adjusted makefile to link during Shared Library creation.
LOCAL_LDLIBS is meaningless for a static library (static libraries don't get linked). You need to add those libraries whenever you use that library in a real binary (like a shared library or executable).
The solution happened to be building unwind and including some portability headers. See module example here
I'm trying to build a .a file to include in a unity3d asset in order to let people build for iOS.
I get the following error when I try to build a game. (The error is a lot longer than this but it seems to be an issue with std::vector )
Building .a file for iOS. Undefined symbols for architecture armv7s: "std::__1::__vector_base_common:: ..."
I saw here Someon has the same error and the solution is .. "add the -lc++ linker flag to your target's Build Settings"
I've tried this fix in the poroject from which I build the .a file from. When I try to build the library I get this error
Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lC++
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lC++ is not an object file (not allowed in a library)
Note: I'm very inexperienced with osx and xcode.