Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

‘sprintf’ was not declared in this scope when compiling #5

Closed
lanyusea opened this issue Aug 5, 2014 · 3 comments
Closed

‘sprintf’ was not declared in this scope when compiling #5

lanyusea opened this issue Aug 5, 2014 · 3 comments

Comments

@lanyusea
Copy link

lanyusea commented Aug 5, 2014

I'm trying to compile the code using g++
g++ -c -o main.o main.cpp
but there is a error saying
main.cpp:36:58: error: ‘sprintf’ was not declared in this scope

I'm a little confused when I include the stdio.h in main.cpp directly, there are lots of errors when compiling saying: undefined reference

any suggestion?

@delmottea
Copy link
Owner

I think it's stdio.h.
undefined reference means that you have successfully compiled the source but have problems in the linker.
Did you add the flags to link openCV? somethink like -lopencv_core,...

@lanyusea
Copy link
Author

lanyusea commented Aug 6, 2014

thanks @delmottea , you are right. I'm not quite familiar with the compile of OpenCV.

I added the CMakeLists.txt file, using TARGET_LINK_LIBRARIES( cmtcpp ${OpenCV_LIBS} ) to link the OpenCV Libaray, which works well.

and using INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}") to link the cmt.cpp, but still get the undefined reference of CMT::

can you give me some advice?

@lanyusea
Copy link
Author

lanyusea commented Aug 6, 2014

I solved that by adding another TARGET_LINK_LIBRARIES with ${CMAKE_CURRENT_SOURCE_DIR}/CMT.cpp

@lanyusea lanyusea closed this as completed Aug 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants