Reputation: 5919
I have a c++ library which does opengl (es 2.0) rendering and I want to use it on android. When linking the library with target_link_libraries(mylib log GLESv2)
I receive the following error:
ld: error: cannot open crtbegin_so.o: No such file or directory
ld: error: cannot open crtend_so.o: No such file or directory
ld: error: cannot find -llog
ld: error: cannot find -lGLESv2
ld: error: cannot find -lm
ld: error: cannot find -lstdc++
ld: error: cannot find -lm
ld: error: cannot find -ldl
ld: error: cannot find -lc
ld: error: cannot find -ldl
If I provide a specific directory from android ndk manually it works. In cmake this looks similar to this:
link_directories( ${ANDROID_NDK}/platforms/${ANDROID_API}/arch-${ANDROID_ABI}/usr/lib )
I'm wondering if this is the correct way to solve the error. In this simple example the additional definition of link_directories is not needed. What is the difference to my library?
Upvotes: 0
Views: 721
Reputation: 5919
The cause for this was quite simple. I was overwriting the compiler flags in my cmake files:
SET(CMAKE_CXX_FLAGS "-foo" )
when I changed this to
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -foo" )
the linking problems are gone.
Upvotes: 2