Can I create a so file for CMAKE Project, using QT?
-
using QT 5.6.3 version
NewProject -> C++Library -> Shared Library
made a project for so file and added a simple working function.
I think i followed the basic form of shared library project.
and built it, bring it to my CMAKE Project, added like below
INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)
find_library(
libmy
NAMES libmy_hello.so
HINTS ./lib
REQUIRED
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})undefined reference to 'simple function' error occured.
I do not reckon where i did wrong...
any answer would be appriciated
-
using QT 5.6.3 version
NewProject -> C++Library -> Shared Library
made a project for so file and added a simple working function.
I think i followed the basic form of shared library project.
and built it, bring it to my CMAKE Project, added like below
INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)
find_library(
libmy
NAMES libmy_hello.so
HINTS ./lib
REQUIRED
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})undefined reference to 'simple function' error occured.
I do not reckon where i did wrong...
any answer would be appriciated
@manykim said in Can I create a so file for CMAKE Project, using QT?:
undefined reference to 'simple function' error occured.
Either you're not linking properly (lib not found or is not compatible), or you did not export simple_function in your lib.
-
@manykim said in Can I create a so file for CMAKE Project, using QT?:
undefined reference to 'simple function' error occured.
Either you're not linking properly (lib not found or is not compatible), or you did not export simple_function in your lib.
@jsulm sir please tell me more, I think, because i cannot find any special error in CMAKE project, link was done correctly... then how can I export my function? i put the macro for "Q_DECL_EXPORT" before function name in header file. was it enough? sorry for my bad language
-
@manykim said in Can I create a so file for CMAKE Project, using QT?:
undefined reference to 'simple function' error occured.
Either you're not linking properly (lib not found or is not compatible), or you did not export simple_function in your lib.
-
@jsulm sir please tell me more, I think, because i cannot find any special error in CMAKE project, link was done correctly... then how can I export my function? i put the macro for "Q_DECL_EXPORT" before function name in header file. was it enough? sorry for my bad language
@manykim said in Can I create a so file for CMAKE Project, using QT?:
link was done correctly
How can it be correct if you get "undefined reference" linker error?!
Regarding exporting symbols in libraries: please read https://doc.qt.io/qt-6/sharedlibrary.html
-
using QT 5.6.3 version
NewProject -> C++Library -> Shared Library
made a project for so file and added a simple working function.
I think i followed the basic form of shared library project.
and built it, bring it to my CMAKE Project, added like below
INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)
find_library(
libmy
NAMES libmy_hello.so
HINTS ./lib
REQUIRED
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})undefined reference to 'simple function' error occured.
I do not reckon where i did wrong...
any answer would be appriciated
-
@manykim said in Can I create a so file for CMAKE Project, using QT?:
link was done correctly
How can it be correct if you get "undefined reference" linker error?!
Regarding exporting symbols in libraries: please read https://doc.qt.io/qt-6/sharedlibrary.html
-
using QT 5.6.3 version
NewProject -> C++Library -> Shared Library
made a project for so file and added a simple working function.
I think i followed the basic form of shared library project.
and built it, bring it to my CMAKE Project, added like below
INCLUDE_DIRECTORIES(/usr/local/include/opencv4 ./includes)
find_library(
libmy
NAMES libmy_hello.so
HINTS ./lib
REQUIRED
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS1} ${OpenCV_LIBS2} ${OpenCV_LIBS3} ${OpenCV_LIBS4} ${libmy})undefined reference to 'simple function' error occured.
I do not reckon where i did wrong...
any answer would be appriciated
@manykim said in Can I create a so file for CMAKE Project, using QT?:
I do not reckon where i did wrong...
Did the linker even find your my_hello library?
Post the link related commands and output executed by the Makefile that CMake generated for you.
make VERBOSE=1
-