Can anybody tell me how to compile the opengl code in emacs just like we do in visual studio?
What we should do you link the library in emacs to run opengl code in emacs? Is it even possible? I've seen the internet that you can use emacs as you IDE although it is a text editor.
Emacs is just an editor. It doesn't give a iota about what you're writing in it. Sure you can loads a gazillion macros in it, and somewhere someone might have even created a Emacs Lisp implementation of OpenGL. But that's not relevant for this question.
What editor you use is completely irrelevent to programming OpenGL!
I think what you're really interested in is, how to write Makefiles or equivalent for other build systems.
You want to compile OpenGL code? Great! To do so in C or C++ include the OpenGL headers in your source code, i.e.
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
For any other language use the appropriate bindings.
Then add the OpenGL to your linker:
For Windows:
Visual C++: Add opengl32.lib to the list of extra libraries
MinGW / GCC / Clang: Add -lopengl32 to the linker stage
For Linux:
If linking for GLvnd (recommended): Add -lOpenGL to the linker stage
If not using GLvnd: Add -lGL to the linker stage
For macOS: Add -framework OpenGL to the compiler and linker stages.
Related
I'm using android NDK r8d, and eclipse Juno. I'm trying to compile C++ code which uses C++11 stuff like mutex, lock_guard, shared_ptr, etc. in a native android project in eclipse.
I get errors like:
"error: 'shared_ptr' is not a member of 'std'"
"fatal error: mutex: No such file or directory"
I came across a similar question here. It seems to work for them, but the explanation there is not complete so I can't get it to work for me.
I added "NDK_TOOLCHAIN_VERSION=4.7" to the Application.mk and "LOCAL_CFLAGS += -std=c++11" to Android.mk file. Still, it doesn't compile.
In the link above it says:
"Be sure that the standard library include path (like
/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include) is in the
target settings."
How and where do I insert it?
I also get errors in eclipse IDE (on the source, before compiling). I know I should define "__GXX_EXPERIMENTAL_CXX0X__" to resolve them but I just don't know where to put it.
So, if someone could post an answer with a full explanation of how to compile and make eclipse work with C++11 it would be great.
Regarding your first question:
Go to Project > Properties > C/C++ General / Paths and Symbols
In the "Includes" tab, add the proper directory, e.g.
/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include
Regarding your second question, I'm also looking for an answer. It is absolutely not clear how to define the GXX_EXPERIMENTAL_CXX0X macro in Eclipse.
Some say that it should be "added as a predefined macro to the indexer", but it looks like we both could not find a way to implement that...
I have read elsewhere that it should be added to "C/C++ General / Paths and Symbols / Symbols / GNU C++" but I can't find the "Symbols / GNU C++" part in my version of Indigo.
I find export an environment variable NDK_TOOLCHAIN_VERSION=4.8 before i start eclipse can solve this problem.
Eclipse use ndk's default toolchain version 4.6, if NDK_TOOLCHAIN_VERSION is not define, and gcc witch this version does not support all c++11's future like multithread and so on.
i want to use gtksourceview in my c++ project. I dig around the IDE of code::blocks and really find it helpfull. i specify gtkmm directory in linker and include options but as i look for gtksourceview i found a libgtksourceview-2.0-0.dll file i really don't know how to add this in code::blocks and use gtksourceview. I am have programming experience in C for microcontrollers just and now i have not really idea about the compilation process of gcc and g++. and can i able to add the file directives as
#include <gtksourceview/gtksourceview.h>
please help
sorry if it seems so basic question for someone but i really stuck of to compile the code and then asking.
I am using windows by the way.
Thanks in advance
There are two different things: the runtime libraries and the development headers. The former allows you to run the applications (also to link them), the later to compile them. Either you are missing the header files (gtksourceview.h in your example) or setting the PATH in your IDE to find the header files.
Check the manual for 'Including libraries'.
I am reading through a "Getting Started with OpenGL" tutorial and I came across this text:
"If you are using C/C++, then you must first set up a build environment (Visual Studio project, GNU makefile, CMake file, etc) that can link to OpenGL. Under Windows, you need to statically link to a library called OpenGL32.lib (note that you still link to OpenGL32.lib if you're building a 64-bit executable. The "32" part is meaningless). Visual Studio, and most Windows compilers, come with this library."
I am just trying to write my source files using vim, I don't want to use an IDE like VS, and from my understanding the OpenGL libraries come with Windows 7 (correct me if I'm wrong). After this point the article doesn't really go into any more detail about how to include the OpenGL libraries, and my real question is, how do I include and use the OpenGL libraries in my source files?
Is it as simple as writing #include <name of lib> or do I need to do something else with my Programming environment like editing my path variables?
Edit: I'm using the MinGW g++/gcc compiler
To get access to the include files, you need a special support library. There are more than one of these, but I would recommend GLEW. You can find the GLEW interface at http://glew.sourceforge.net/.
The reason for this is that only a very old version of OpenGL headers are available as default on Windows. The newer interface is available indirectly; you have to ask for function addresses. This is however done by GLEW for you.
So you only have to include < GL/glew.h>, and do some initialization with glewInit();
This is compatible with both Linux and Windows, especially as you use MinGW. When linking, I use the following:
MY_LIBS =
-lglew32
-lopengl32
-lWs2_32 -lole32 -lcomctl32 -lgdi32 -lcomdlg32 -luuid
I can recommend the use of a generic makefile, see http://sourceforge.net/projects/gcmakefile/
Notice that you also have to setup a context for OpenGL, before initializing GLEW. This is done differently depending on the environment. It is done when you open a window. For portable libraries, I can recommend the glfw library or freeglut.
Where could I find C++ libraries in my emacs? I have already installed emacs on my computer and already using it lately. I just want to add boost libraries in emacs so I could use them.
Emacs is a text editor, it doesn't compile your code.
It doesn't know (or need to know) anything about your libraries.
However, there are commands for running the compiler from inside emacs, I've never done it myself, I use command line compiling and makefiles for bigger projects.
I would write the program using the boost libraries (or any libraries) just like normal.
I'm guessing you'd use GCC to compile as you're using emacs to edit.
When compiling you need to tell the compiler (GCC) where to look for the header files and the libraries.
For example,
in your program you will have a line like
#include <library.h>
then compile it using
g++ myprogram.cpp -I/path/to/header/files -L/path/to/library
If your program is more than a couple of files, I would recommend writing a makefile for it and including all the required compiler flags and search paths in the makefile.
You need to supply them in your make script, or you can set an environment value for GCC. Take a look at this question.
You could use CEDET to setup parsing of header files. Please look to my CEDET config for example
Where can I find an writeup that shows me how to set up a tool chain for WxWidgets (C++) on linux/ubunto and/or OS X.
I downloaded, compiled & installed WxWidgets both on linux and OS X, compiled and tried the samples, but seem to be stuck setting up a compile environment in my own home directory.
DialogBlocks from http://www.dialogblocks.com looked promising, but it insists on recompiling WxWidgets again and again .. must be something about it I don't understand.
Writing code from scratch seems to fail due to a lack of paths to libraries, tools or whatnot .. again a lack og understanding on my part, I am sure.
So, can anyone point me to a tool chain setup, that has more than the bare minimum of instructions and fills in some of the "why" instead of only the minimal "what".
Like all C/C++ programs, the compiler has to know in what directories to look for include files, and the linker has to know what libraries it should link to.
The WxWidgets package, if installed correctly, includes the program wx-config. This can be used while compiling and linking, like so:
g++ $(wx-config --cxxflags) -c my_prog.cpp
g++ my_prog.o $(wx-config --libs) -o my_prog
I've found these two pages to be of help when setting up wxWidgets for Eclipse and MinGW.