i try include some botan header in compilation process
#include <botan/rng.h>
#include <botan/auto_rng.h>
#include <botan/cipher_mode.h>
#include <botan/hex.h>
#include <iostream>
int main(int argc, char** argv)
{
return 0;
}
I found that i need to compile with following command in order to build successfully
g++ app.cpp -I/usr/local/include/botan-2
i saw some folks execute
g++ app.cpp -lbotan-2
i tried it out but i get a error
'app.cpp:1:10: fatal error: botan/rng.h: No such file or directory
#include <botan/rng.h>
Am i missing anything ?
The following command:
g++ app.cpp -lbotan-2
links botan-2 with app.cpp but you still need to specify where to find the headers:
g++ app.cpp -I/usr/local/include/botan-2 -lbotan-2
Under my system, the headers for botan-2 are in /usr/include/botan-2. So, make sure you are giving the right path.
Related
I'm trying to make a cookie clicker clone and when I include the SDL_ttf header file, I get an error. How do I resolve this error?
#include <iostream>
#include <SDL2\SDL.h>
#include "..\SDL2_ttf-2.0.15\i686-w64-mingw32\include\SDL2\SDL_ttf.h"
I compile with:
g++ -o test test.cpp -I../SDL2-2.0.16/i686-w64-mingw32/include -L../SDL2-2.0.16/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2
I got this error message:
In file included from test.cpp:3:0:
..\SDL2_ttf-2.0.15\i686-w64-mingw32\include\SDL2\SDL_ttf.h:34:17: fatal error: SDL.h: No such file or directory
#include "SDL.h"
I'm on a windows machine (windows 10) and using sublime.
Put the -lSDL2_ttf flag in the compile line
I want to write simple C codes to use the functions in ModemManager 1.4.12 to use some of the functions provided in ModemManager to do modem related functions.
I have added the headers I need:
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <glib.h>
#include <gio/gio.h>
#include <libmm-glib.h>
#include "mmcli.h"
#include "mmcli-common.h"
Compile with gcc -o test test.h
but it complains that glib.h is not found.
When I compile with:
gcc -Wall pkg-config --cflags libnm pkg-config --cflags --libs gio-2.0
it complains that fatal error: libmm-glib.h: No such file or directory
When I use -I to include libmm-glib.h, it complains that ModemManager.h is not found.
Should I keep Adding directories with -I or is there a more proper way of doing it?
Thanks
It is not clear what you want to accomplish...
Do you want to build a separate program that uses libmm-glib to talk to ModemManager via DBus? If so:
/* save as test.c and compile with:
* $ gcc -o test `pkg-config --cflags --libs mm-glib` test.c
*/
#include <libmm-glib.h>
int main (int argc, const char **argv)
{
...
}
Note that pkg-config requesting mm-glib cflags/libs should be enough, as that will pull any additional dependency cflags/libs, like glib/gobject/gio.
But from the looks of your code sample, you're also adding mmcli specific headers... so do you want to extend mmcli with new capabilities? If so, instead of giving custom gcc commands, you should extend the mmcli sources and if you need to add new files in the compilation of mmcli, just modify the Makefile.am under cli/.
I get the error
"/usr/include/c++/5/cstddef:51:11: error: ‘::max_align_t’ has not been declared
using ::max_align_t;
^"
So I should update the libraries because I find this solution:
"A workaround until libraries get updated is to include <cstddef> or <stddef.h> before any headers from that library."
I wrote some command on the Ubuntu terminal such as:
bash $ sudo apt-get install apt-file
bash $ sudo apt-file update
bash $ apt-file search stddef.h
Then still the error exist.
Thank you
In the .cpp file where this compile error occurs you need to add
#include <cstddef>
before any of the other headers, e.g.
main.cpp (broken)
#include <cstdio>
int main()
{
using ::max_align_t;
puts("Hello World");
return 0;
}
Try to compile that:
$ g++ -std=c++11 -o test main.cpp
main.cpp: In function ‘int main()’:
main.cpp:5:10: error: ‘::max_align_t’ has not been declared
using ::max_align_t;
^
Then fix it:
main.cpp (fixed)
#include <cstddef>
#include <cstdio>
int main()
{
using ::max_align_t;
puts("Hello World");
return 0;
}
Compile and run it:
$ g++ -std=c++11 -o test main.cpp
$ ./test
Hello World
I compiled some code with GNU C++ 4.9 on CentOS, and the issue was not solved by ensuring top position #include (or by the older header name stddef.h).
Weird enough, I searched all header files of the compiler libraries for the global definition of max_aling_t as declared in the offending using declaration... and found none! Could it be in some 'internal compiled header?
So I simply commented-out the "using ::max_align_t;" line in the standard header (not proud of doing this indeed) and it solved the problem... and code is running...
if anyone can explain what is the meaning/impact of this max_align_t ?
I also commented-out the using ::max_align_t; line in /usr/include/c++/4.9/cstddef, while, code is running, but I don't know if there are any consequences by doing this...
I setup SDL2 under C++ CDT Eclipse.
I added the include path "........SDL2-2.0.3\i686-w64-mingw32\include", the library path "........SDL2-2.0.3\i686-w64-mingw32\lib" and added the libraries 1."mingw32" 2."SDL2main" 3."SDL2".
So now, if I add a main.cpp with this content:
#include <SDL.h>
int main(int argc, char* args[])
{
return 0;
}
I can build the project fine, but if I use this:
#include <SDL.h>
int main()
{
return 0;
}
The project can't build and I get this error:
Info: Internal Builder is used for build g++ "-IO:\Eclipse CDT
Workspace\SDL OpenGL Lab\Libraries\SDL2\include\SDL2" -O0 -g3
-Wall -c -fmessage-length=0 -o main.o "..\main.cpp" g++ "-LO:\Eclipse CDT Workspace\SDL OpenGL Lab\Libraries\SDL2\lib" -o
"SDL OpenGL Lab.exe" main.o -lmingw32 -lSDL2main -lSDL2 O:\Eclipse
CDT Workspace\SDL OpenGL
Lab\Libraries\SDL2\lib/libSDL2main.a(SDL_windows_main.o): In function
console_main':
/Users/slouken/release/SDL/SDL2-2.0.3-source/foo-x86/../src/main/windows/SDL_windows_main.c:140:
undefined reference toSDL_main' collect2.exe: error: ld returned 1
exit status
I simply wonder me why this error is depending on my main method, I want to use the main method I want.
Why this is so, how I can fix this ?
Sorry, you're stuck with it. I also preferred a simpler main, but SDL doesn't support it.
Here's a little more on SDL and main in the Windows world. It doesn't say why you need their version of main -- but you do.
I get "Undefined reference to 'SDL_main'" ...
Make sure that you are declaring main() as:
#include "SDL.h"
int main(int argc, char *argv[])
https://wiki.libsdl.org/FAQWindows
I had the same problem and had to go through a lot of manipulations.
What I have found is the simple line #define SDL_MAIN_HANDLED before calling SDL.h. SDL has his own main that's why, I think.
For example, in my .h files, I write everytime this :
#include <stdio.h>
#include <stdlib.h>
#define SDL_MAIN_HANDLED
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
I have a file with the following imports:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
#include <vector>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <glfw3.h>
GLFWwindow* window;
// Include GLM
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/norm.hpp>
using namespace glm;
// Include AntTweakBar
#include <AntTweakBar.h>
#include <common/shader.hpp>
#include <common/texture.hpp>
#include <common/controls.hpp>
#include <common/objloader.hpp>
#include <common/vboindexer.hpp>
#include <common/quaternion_utils.hpp> // See quaternion_utils.cpp for RotationBetweenVectors, LookAt and RotateTowards
However, when I try to compile it with
g++ -lglut -lGLU -lGL rotatetest.cpp -o hello.o
I get the following errors:
rotatetest.cpp:7:23: error: GLUT/glew.h: No such file or directory
rotatetest.cpp:10:19: error: glfw3.h: No such file or directory
rotatetest.cpp:14:23: error: glm/glm.hpp: No such file or directory
rotatetest.cpp:15:40: error: glm/gtc/matrix_transform.hpp: No such file or directory
rotatetest.cpp:16:34: error: glm/gtc/quaternion.hpp: No such file or directory
rotatetest.cpp:17:34: error: glm/gtx/quaternion.hpp: No such file or directory
rotatetest.cpp:18:36: error: glm/gtx/euler_angles.hpp: No such file or directory
rotatetest.cpp:19:28: error: glm/gtx/norm.hpp: No such file or directory
rotatetest.cpp:23:25: error: AntTweakBar.h: No such file or directory
I know this code works because a) it's from a tutorial and b) I can successfully run it when it is part of an XCode project, just not as a standalone file.
I am on Mac OS X 10.8.5. Can anyone suggest to me how I can compile this?
The include<> directives in your file ask for OpenGL-related headers in your system include directory. g++ on the command line may be using a different system include directory than XCode is.
Make sure that the extra OpenGL headers (GLFW, GLM, GLUT) are placed in your g++ installation as well.
You probably will also have to do this for the static libraries as well.