Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi guys I am doing an application in c++ for ARM. I have a application prototype which I compiled with cross compilation and it works very nice in the ARM. What I did was this:

First I got the .o file like this

arm-linux-g++ -c PrototipoTRU.cpp    

Then I got the .exe like this (My application use thread)

arm-linux-g++ PrototipoTRU.o -o tru2 -pthread

and everything works perfect.

My problem is when I tried to compile an .cpp file which use OpenCV. I tried that:

First I tried to got the .o:

 arm-linux-g++ -c camera.cpp

That does not work, I got this output:

IPCamera.cpp:5:30: error: opencv2/opencv.hpp: No such file or directory
IPCamera.cpp:6:39: error: opencv2/highgui/highgui.hpp: No such file or directory
IPCamera.cpp:7:39: error: opencv2/imgproc/imgproc.hpp: No such file or directory
IPCamera.cpp:11:22: error: X11/Xlib.h: No such file or directory
IPCamera.cpp:16: error: 'cv' is not a namespace-name
IPCamera.cpp:16: error: expected namespace-name before ';' token
IPCamera.cpp: In function 'int main(int, char**)':
IPCamera.cpp:46: error: 'cv' has not been declared
IPCamera.cpp:46: error: expected ';' before 'cap'
IPCamera.cpp:52: error: 'Display' was not declared in this scope
IPCamera.cpp:52: error: 'disp' was not declared in this scope
IPCamera.cpp:52: error: 'XOpenDisplay' was not declared in this scope
IPCamera.cpp:53: error: 'Screen' was not declared in this scope
IPCamera.cpp:53: error: 'scrn' was not declared in this scope
IPCamera.cpp:53: error: 'DefaultScreenOfDisplay' was not declared in this scope
IPCamera.cpp:63: error: 'cv' has not been declared
IPCamera.cpp:63: error: expected ';' before 'frame'
IPCamera.cpp:66: error: 'cv' has not been declared
IPCamera.cpp:66: error: 'CV_WINDOW_NORMAL' was not declared in this scope
IPCamera.cpp:68: error: 'cvMoveWindow' was not declared in this scope
IPCamera.cpp:73: error: 'CV_WND_PROP_FULLSCREEN' was not declared in this scope
IPCamera.cpp:73: error: 'CV_WINDOW_FULLSCREEN' was not declared in this scope
IPCamera.cpp:73: error: 'cvSetWindowProperty' was not declared in this scope
IPCamera.cpp:79: error: 'cap' was not declared in this scope
IPCamera.cpp:82: error: 'frame' was not declared in this scope
IPCamera.cpp:89: error: 'cv' has not been declared
IPCamera.cpp:92: error: 'cv' has not been declared

So it seem that there is some problem with the link, however if do this:

 g++ -c IPCamera.cpp

I got the .o file, but obviously when I get the .exe it does not work in the ARM . What I do not undestand is why if I compile an application without opencv, like the first example, the arm-linux-g++ works propertly and when I try to compile the openCV application no.

I tried to compiler also like this:

 arm-linux-g++ -c IPCamera.cpp `pkg-config opencv --libs --cflags`

but is the same result, however if I do this:

 g++ -c IPCamera.cpp `pkg-config opencv --libs --cflags`

It works. So I guess that is a path problem but I do not have idea how I can solved it.

Someone can help me??

Thank you guys

Hi dennisfen this is the content of mi file:

 set(CMAKE_SYSTEM_NAME Linux)
 set(CMAKE_SYSTEM_VERSION 1)
 set(CMAKE_SYSTEM_PROCESSOR arm)

 set(GCC_COMPILER_VERSION "4.6" CACHE STRING "GCC Compiler version")

 set(FLOAT_ABI_SUFFIX "")

 if (NOT SOFTFP)
   set(FLOAT_ABI_SUFFIX "hf")
 endif()

 set(CMAKE_C_COMPILER    arm-linux- 
 gnueabi${FLOAT_ABI_SUFFIX}-gcc-${GCC_COMPILER_VERSION})
 set(CMAKE_CXX_COMPILER  arm-linux-
 gnueabi${FLOAT_ABI_SUFFIX}-g++-${GCC_COMPILER_VERSION})
 set(ARM_LINUX_SYSROOT /usr/arm-linux-gnueabi${FLOAT_ABI_SUFFIX} CACHE PATH "ARM cross 
 compilation system root")

 set(CMAKE_CXX_FLAGS           ""                    CACHE STRING "c++ flags")
 set(CMAKE_C_FLAGS             ""                    CACHE STRING "c flags")
 set(CMAKE_SHARED_LINKER_FLAGS ""                    CACHE STRING "shared linker flags")
 set(CMAKE_MODULE_LINKER_FLAGS ""                    CACHE STRING "module linker flags")
 set(CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"  CACHE STRING "executable linker 
 flags")

 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack 
 -fsigned-char -Wno-psabi")
 set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack 
 -fsigned-char -Wno-psabi")

 set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-
 sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_SHARED_LINKER_FLAGS}")
 set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-
 sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_MODULE_LINKER_FLAGS}")
 set(CMAKE_EXE_LINKER_FLAGS    "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-
 sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_EXE_LINKER_FLAGS}")
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
263 views
Welcome To Ask or Share your Answers For Others

1 Answer

It seems that you need to set include path to your cross OpenCV installation:

arm-linux-g++ -I/path/to/opencv/include IPCamera.cpp -o tru2

When you call pkg-config it reports settings for you host system not for your arm cross toolchain.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...