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
Related
C++ newbie here, I have this game engine I am making and I would like to export it into .dll and use it in a sandbox project. It depends on GLFW, spdlog and Vulkan. I am using g++ on Windows with Cygwin.
Here is a simple version of my project:
Sandbox
|----Sandbox.cpp
Engine
|----Engine.h
|----vendor
|----glfw
|----spdlog
So Sandbox.cpp includes <Engine.h>, Engine.h includes <GLFW/glfw3.h>
Here are my commands:
First compile from Engine:
g++ -std=gnu++11 -I someIncludeDir -c someCPP.cpp -o objectFiles.o
Then build dll:
g++ -shared -o objectfiles.o -L./path/to/GLFW/DLL -L"C:\Windows\System32" -lglfw3 -lopengl32 -lgdi32 -lvulkan-1 cygxxx.dll -Wl,--out-implib,libxxx.dll.a
This will give me a cygxxx.dll and libxxx.dll.a.
I moved these 2 files into Sandbox project.
Compile the Sandbox project:
g++ -std=gnu++11 -I../Engine/Engine.h someCPP.cpp -c objectfiles.o
And this is where I got the error saying <GLFW/glfw3.h> not found.
My confusion is, I don't want to include GLFW or Vulkan in my Sandbox project, nor do I want to include them in my compiler flag. Is this even possible?
Please help a C++ noob.
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?
So recently I downloaded the Linux Subsystem on Windows 10, with Ubuntu.
I can compile an SDL2 app to Linux with the g++ command but whenever I try doing it with i686-w64-mingw32-g++ this command, I get an error saying main.cpp:5:9: fatal error: SDL2/SDL.h: No such file or directory.
The command I'm using is i686-w64-mingw32-g++ main.cpp -w -lSDL2 -o main.exe.
https://imgur.com/a/uqcGCoJ
Anyone knows how to fix this? :(
[EDIT]
So now I've tried specifying the directory of the necesary files with this command: g++ main.cpp -I/usr/include/SDL -L/usr/lib/x86_64-linux-gnu -w -Wall -Wextra -std=c++17 -lSDL2 -o main
which worked but when I use it with mingw it doesn't i686-w64-mingw32-g++ main.cpp -I/usr/include/SDL -L/usr/lib/x86_64-linux-gnu -w -Wall -Wextra -std=c++17 -lSDL2 -o main
https://imgur.com/a/sF6CpcP
You need to include the path to SDL's include directory on the command line. However, you need to include the path to the downloaded SDL for mingw32, not /usr/include/SDL2. The difference is the headers in /usr/include/SDL2 are for Linux and libs in /usr/lib are also for Linux, but you need to link to the Windows libraries.
What I usually do is download the development libraries for Mingw32 and put them directly into my project directory. Then all you need to do is add -ISDL2-2.0.8/i686-w64-mingw32/include -LSDL2-2.0.8/i686-w64-mingw32/lib to your command line and it will be able to find the headers and libraries it needs. Finally, make sure you copy SDL2-2.0.8/i686-w64-mingw32/bin/SDL2.dll to your executable directory in the Makefile.
Also, remember to link SDLmain as well. It handles creating a WinMain for you and all that, and then calls your main function.
I am refactoring an old Borland C/C++98 program. I would like to program it under linux platform but to beginning, as I have severals additionnals boards, I clean the program, remove all GUI OWL and make tests under win7 and mingw64 to use modern gcc/g++.
I actually try to link a sample code that use C320 turbo Moxa multiport serial board.
As mentionned in
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
it should link .lib and .dll.
So I tried to link my sample with Moxa PComm.lib for sio_open, sio_read, sio_write… functions as
g++ -m32 -Wall -std=c++14 src/main.cpp src/rs232_c320t.cpp … -L./lib -lPComm
and it returns
./lib/PComm.lib: file not recognized: File format not recognized
Are there any options to allow link windows .lib with gcc/g++ under mingw64?
Thanks
This related "Linking *.lib files with MinGW" question doesn't mention "File format not recognize" error. See also my comments below.
bcag2
I downloaded last PCommLite for win7 x64.
Copy C:\Program Files\Moxa\PCommLite 1.6\Include\PCOMM.H in my include project folder (lib in my case), and do the same for files PCOMM.dll and PCOMM.lib in C:\Program Files\Moxa\PCommLite 1.6\Lib\x64.
Then I compile with:
g++ -c -std=c++14 -D_hypot=hypot -DWIN32 src/*.cpp -I./lib/
Where -I./lib give access to PCOMM.H and link with:
g++ -shared *.o lib/PCOMM.LIB /c/Windows/System32/msvcr120.dll /c/ProgramData/Anaconda3/python36.dll -o _project.pyd
Of course you can do all in one time and create an .exe:
g++ -o project.exe -Wall -std=c++14 -DWIN32 src/*.cpp -Ilib/ lib/PCOMM.LIB -L./lib/
NO -ansi required as suggested by Moxa support!
I know that it is possible to make .dylib files with g++ compiler on the MacOSX platform. I want to make a .framework grouping headers and library. Is it possible to use g++ compiler for that? If not is there any command line interface tool for that purpose? (I want to avoid using xCode if possible)
I know you said you wanted to avoid using Xcode, but here is a nice link https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html Follow the instructions ONLY for creating the framework, you'll get a .framework file. With the .framework file that you can place anywhere in your computer, you can compile outside of Xcode like so.
if in your current directory:
cwd=$(pwd)
g++ -Wall somefiles.c -o run "-I $(pwd)/some/path/name.framework -F $(pwd)/some/path/ -framework name"
otherwise
g++ -Wall somefiles.c -o run "-I /full/path/name/name.framework -F /full/path/name/ -framework name"