I am trying to create a c++ application with a graphical interface and thus I am trying to Implement OpenGL with SDL. I am working on a Ubuntu Subsystem for Windows 10. I already installed the sdl and gl libraries but now when I am compiling my code with
g++ -o glpractice glpractice.cpp -Wall $(sdl-confiig --cflags --libs) $(pkgconf gl --libs)
it returns the error
g++: error: unrecognized command line option '-mwindows'
How do I fix that or work around it?
Related
I can cross compile a simple C++ program. (ex. g++ -o test test.cpp & arm-linux-gnueabihf-g++ -o test test.cpp).
But when I include OpenCV header files in a C++ program and cross compile it, it throws an error.(ex. arm-linux-gnueabihf-g++ -o ocv_test ocv_test.cpp $(pkg-config --libs --cflags opencv)).
Also I can compile successfully with the default compiler i.e. g++.(ex. g++ -o ocv_test ocv_test.cpp $(pkg-config --libs --cflags opencv))
I executed cmake with
-D CMAKE_TOOLCHAIN_FILE=../platforms/linux/arm.toolchain.cmake \.
as per the opencv docs. That didn't help.
I added opencv include dir in compilation cmd ie -I/path/to/opencv/include and removing pkg-config. That didn't help.
I tried changing arm-gnueabi.toolchain.cmake by exporting PKG_CONFIG_LIBDIR as per suggestion by someone. That didn't help.
I got the following error:
__/usr/lib/gcc-cross/arm-linux-gnueabihf/7/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_shape
//usr/local/lib/libopencv_stitching.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status__
I want my cross-compiled OpenCV app to run on a RaspberryPI.
I'm confused. Cross compiling OpenCV sources with the -D CMAKE_TOOLCHAIN_FILE option should allow us to cross-compile OpenCV C++ programs. Otherwise we will have to cmake or make (cross-compile) every OpenCV C++ program seperately on a build machine.
I am using a new install of cygwin with glut32 libraries on a Windows 7 64-bit machine. I am trying to put together a test program in C++ using the Eclipse IDE. Standard terminal programs and a test GLUT32 program build and run as expected. I am trying to hide the console window on a release build of my test program.
I attempted to use the -mwindows flag in the linker step to suppress the console window, but I get the following:
11:15:04 **** Incremental Build of configuration Release for project Test ****
make all
Building file: ../src/Test.cpp
Invoking: Cygwin C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Test.d" -MT"src/Test.o" -o "src/Test.o" "../src/Test.cpp"
Finished building: ../src/Test.cpp
Building target: Test.exe
Invoking: Cygwin C++ Linker
g++ -L"C:\cygwin\lib" -Xlinker -mwindows -shared -o "Test.exe" ./src/Test.o -lglut32 -lglu32 -lopengl32
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: unrecognised emulation mode: windows
Supported emulations: i386pep i386pe
collect2: error: ld returned 1 exit status
make: *** [makefile:47: Test.exe] Error 1
11:15:05 Build Finished (took 376ms)
I think the supported emulation statement might be a hint. Am I somehow using the wrong compiler? How do a build a finished program without having a console windows pop up in the background?
I can't explain why, but the problem is solved when I use the -mwindows flag in the compilation step as opposed to the linking step. Program builds with no problems and runs without the console.
my.cpp file has #import <OpenGLES/ES2/glext.h>. I am trying to compile it by g++ -c my.cpp which fails with fatal error: 'OpenGLES/ES2/glext.h' file not found #import <OpenGLES/ES2/glext.h>
I am able to compile it from Xcode with GLKit.framework. How to compile it in macOS from command line?
--EDIT--
Where are the OpenGL header files located on MacOSX? seems relevant but it is to OpenGL. I am looking for OpenGL ES
The include path shown by Xcode is
but I couldn't figure out its location in the file system to use with compiler's -I option
The key to solving would be specifying the OpenGLES location:
g++ -c my.cpp -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk/System/Library/Frameworks -framework OpenGLES
The -F flag indicates the library location, and -framework
indicates which framework to use.
Technically -isysroot could work as well:
g++ -c my.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk
I have read all of the related questions with no success trying anything mentioned anywhere. I am new to cross-compiling and have been working on this for over a week with no progress. So please forgive me if you think I am stupid or have overlooked something.
So I have an application running in C++ that works great on my development computer running Ubuntu 14.04 x64. I am trying to cross compile for my Banana Pro running Lubuntu. Based on the documentation from Lemaker I am supposed to cross compile using "arm-linux-gnueabihf-"
So far the farthest I have been able to get is to :
/usr/local/opencv-arm/usr/local/lib/libopencv_calib3d.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
I get this error regardless of what command I run, Here is a list of commands I have tried:
arm-linux-gnueabihf-g++ `arm-linux-gnueabihf-pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `arm-linux-gnueabihf-pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-gcc `pkg-config arm-opencv --cflags` -Wall test.cpp -o vis-300 `pkg-config arm-opencv --libs`
arm-linux-gnueabihf-g++ `pkg-config arm-opencv --cflags` test.cpp -o vis-300 `pkg-config arm-opencv --libs`
And there have been many more commands before those with different errors such as:
arm-linux-gnueabihf-gcc: error trying to exec 'cc1plus': execvp: No such file or directory
arm-linux-gnueabihf-cpp fatal error too many input files
I have tried with just normal arm-linux-gnueabihf-gcc/g++, 4.6, 4.7, and 4.8
I have built opencv making small changes for hf using these 2 guides and both produced the same results:
http://processors.wiki.ti.com/index.php/Building_OpenCV_for_ARM_Cortex-A8
http://www.ridgesolutions.ie/index.php/2013/05/24/building-cross-compiling-opencv-for-linux-arm/
and not included in either I install it using this command because it will conflict with my current x86_64 install:
sudo make install DESTDIR=/usr/local/opencv-arm
Also the above pkg-config lines point to my custom pkg config file named arm-opencv.pc
# Package Information for pkg-config
prefix=/usr/local/opencv-arm/usr/local
exec_prefix=${prefix}
libdir=
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include
Name: OpenCV-arm
Description: Open Source Computer Vision Library
Version: 2.4.10
Libs: ${exec_prefix}/lib/libopencv_calib3d.so ${exec_prefix}/lib/libopencv_contrib.so ${exec_prefix}/lib/libopencv_core.so ${exec_prefix}/lib/libopencv_features2d.so ${exec_prefix}/lib/libopencv_flann.so ${exec_prefix}/lib/libopencv_gpu.so ${exec_prefix}/lib/libopencv_highgui.so ${exec_prefix}/lib/libopencv_imgproc.so ${exec_prefix}/lib/libopencv_legacy.so ${exec_prefix}/lib/libopencv_ml.so ${exec_prefix}/lib/libopencv_nonfree.so ${exec_prefix}/lib/libopencv_objdetect.so ${exec_prefix}/lib/libopencv_ocl.so ${exec_prefix}/lib/libopencv_photo.so ${exec_prefix}/lib/libopencv_stitching.so ${exec_prefix}/lib/libopencv_superres.so ${exec_prefix}/lib/libopencv_ts.a ${exec_prefix}/lib/libopencv_video.so ${exec_prefix}/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl
Cflags: -I${includedir_old} -I${includedir_new}
Anyways I have tried a lot of stuff short of just installing everything on the board itself and compiling there. Any help is much appreciated and keep in mind I have never successfully cross-compiled before. I always give up and compile on the board.
I'm on windows using mingw and when i use the following to try and compile my wxWidgets code
g++ main.cpp `wx-config --libs` `wx-config --cxxflags`
I get the following error
g++: `wx-config: No such file or directory
g++: `wx-config: No such file or directory
cc1plus.exe: error: unrecognized command line option "-flibs`"
cc1plus.exe: error: unrecognized command line option "-fcxxflags`"
And I cannot figure out what to do to make g++ play nice with wx-config
Please help, thanks.
What shell are you using? Back quotes don't work on the Windows command prompt. You may need to use msys and bash.