g++ not finding header files during compilation despite headers existing in include path - c++

I'm trying to run the SFML example found at the bottom of the page here using VSCode and g++.
Before compilation, the SFML include file C:\GL\SFML-master\include is in the C++ Configurations include path. VSCode throws errors if I change this, so I don't believe it's the problem.
However, when I run/debug the file, g++ throws fatal error: SFML/Audio.hpp: No such file or directory
I've tried playing around with the file location and path but I'm not quite sure what is actually going wrong.
The only code in my program is the example above, and the only changes I've made is that to the include path, and of course I actually have SFML downloaded. I'm using g++ 12.1.0 and SFML 2.5.1 if that makes any difference.

Related

SFML not working correctly on mac ./SFML/Window.hpp:32:10: fatal error: 'SFML/System.hpp' file not found

I downloaded and Followed the tutorial on how to install it on mac but when i open Geany and try to include everything from SFML i get an error here's
the error and my include code
The code itself is fine, but you'll have to add SFML's include directory to the include directories looked through by the compiler (or more specific: the preprocessor). Unfortunately I don't know how to set this in xcode though.

glfw3 for code::blocks 16.01 in ubuntu

I am facing a really for me time-expensive problem. I am new to ubuntu and want to start learning more about opengl by using the glfw. Of course I cannot switch the OS so I will have to stay at ubuntu. I have come so far that I installed the glfw( by following this "tutorial": 2. step by filipwasil), so I have got an include directory in the usr/local dir, aswell as a lib directory. The include directory contains the glfw3.h and the lib directory the libglfw3.a file. If I try to add them to my project in code::blocks it seems like only the include part works, because I can see the functions provided by the glfw while typing, but once I want to compile and run the project, I get an error for each glfw function call: like "not defined reference to e.g. glfwInit". The lib directory also contains a cmake dir, which contains glfwconfig and glfwtarget files, but I really do not know what these files should do. I also noticed the question by Artur, which is quiet identical, but it does not help me because I want to know which files exactly I have to add in order to get a running window. So may question is: How is it possible to make the code::blocks IDE, actually the gcc compiler, know whats behind the glfw functions?
Every help will be appreciated. Sorry for my bad english. :)
Add GL, GLEW and glfw in the linker settings. Note the "glfw" in lowercase

How to link against GLFW on Windows

I am looking to learn how to use OpenGL with C++, and I am following the tutorial at open.gl. I am at this part in the tutorial, and I am using GLFW. I tried following the instructions to build GLFW,
After you've downloaded the GLFW binaries package from the website or
compiled the library yourself, you'll find the headers in the include
folder and the libraries for your compiler in one of the lib folders.
-Add the appropriate lib folder to your library path and link with GLFW.
-Add the include folder to your include path.
I downloaded it, and moved the include folder into my MinGW include folder, but I was unsure where to find the lib folder, how to add it to my library path, or how to link it with OpenGL. This was not explained in the tutorial, and I could not find any instruction online about what this meant or how to do it. I proceeded without doing the other two steps, and when attempting to run the test code from the tutorial:
#include <GLFW/glfw3.h>
#include <thread>
int main()
{
glfwInit();
std::this_thread::sleep_for(std::chrono::seconds(1));
glfwTerminate();
}
I received this error:
In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\thread:35:0,
from D:\Files\Documents\Programming\opengl_tut.cpp:2:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
I added -std=c++11 to my compiler flags, and I received this error:
D:\Files\Documents\Programming\opengl_tut.cpp: In function 'int main()':
D:\Files\Documents\Programming\opengl_tut.cpp:7:10: error: 'std::this_thread' has not been declared
std::this_thread::sleep_for(std::chrono::seconds(1));
Thinking the problem might just be with std::this_thread, I removed that line from my program, and ran it to see if initializing and terminating GLFW would return any errors. I got this:
C:\Users\Brett\AppData\Local\Temp\ccCJrDGj.o:opengl_tut.cpp:(.text+0xc): undefined reference to `glfwInit'
C:\Users\Brett\AppData\Local\Temp\ccCJrDGj.o:opengl_tut.cpp:(.text+0x11): undefined reference to `glfwTerminate'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\Brett\AppData\Local\Temp\ccCJrDGj.o: bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
I think this may be because of the fact that I skipped earlier parts of the tutorials.
TL;DR
Tried to follow tutorial to use OpenGL
Couldn't figure out how to link GLFW
Couldn't find lib folder
Got errors relating to std::this_thread
Got error relating to GLFW
EDIT
I found some info on the GLFW site saying to use Cmake. I downloaded it and tried using it to build from the downloaded files. It made a new folder, but I'm not sure what to do with it.
First, it's easy to do such config in Visual Studio, just NuGet, and search glfw, install, Visual Studi/NuGet will handle everything like set proper Include path, Additional Library path, add additional library files
Second, it looks like your link issue, try to add these to your gcc cmd line
g++ -o example.exe example.o -L. -lexample_dll
Third, check the glfw library you downloaded, use MinGW-w64 lib files. Also remember distinguish the static and dynamic libs
It looks like you've downloaded the source files. This will require building (using CMake). You should go download the precompiled binaries. To do this, go back to glfw.org and instead of hitting the download button on the home page, go to the download tab in the top right and under "Windows pre-compiled binaries" select the 32 or 64 bit version and click download. See the attached image
Then, when you extract from the .zip folder you should find in it several folders - the include folder, as well folders with names beginning with "lib" (like lib-mingw, lib-mingw-w64, lib-vc2010, lib-vc2012, etc). You only need one of them, which depends on the compiler you're using - minGW or Visual C++ (vc). Choose the appropriate folder and inside you should find .lib and .dll files.
Now, whenever you compile your OpenGL program, you must tell the compiler (the linker, really) to link those files to your program's object files. You do this by using the proper compiler command line arguments. You can read about doing that in MinGW here: http://mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
For that tutorial you'll probably only need to link glfw3.lib (for MSVC) or libglfw3.a (for MinGW). If you're using GLEW, you'll probably just need glew32.lib and glew32.dll (the latter is found in the "bin" folder not the "lib" folder).
Hope that helps answer your question.

Cannot find -lSDLmain and -lSDL when compiling simple SDL program with g++

I installed SDL2 for mingw using this guide. However, when i try to compile using the compilation syntax and test code they provide, only with my own file names, I get the error shown here. I assume that this error has something to do with a problem in the way I installed SDL, as the installation instructions did not exactly match the files with which I was provided, but I did my best to follow them. Could they problem be something else? If not what is the correct way to install SDL2 for mingw?
Note: I do have the SDL2.dll file in the sdltest folder where I try to compile the program.
One way to let MinGW know where your SDL libraries are would be to create environment variable named "LIBRARY_PATH" with the value as the path to the directory containing the libraries. Similarly, you can have "CPLUS_INCLUDE_PATH" for the headers as well.
Did you follow step 2 of that tutorial ?

Adding C++ to Objective-C, error on #include for cryptlib.h and curl.h

EDIT : OK, I fixed the issue I outlined originally with not being able to find headers for curl and cryptlib. But, after fixing these issues by installing curl and libcryptopp with macports, I encountered a zillion errors in the associated files. I'm marking this answer as complete though
I'm trying to add the Mega.co.nz client SDK to an Objective-C XCode project. The client is written in C++, with .h header files and .cpp implementation files. XCode recognizes these as needing to be compiled with the C++ compiler (I presume).
At this point all I want to do is get the project to compile with no errors. At this time I am getting two errors, both of them on some #include statements.
#include <curl/curl.h> 'curl/curl.h file not found'
#include <crypto++/cryptlib.h> 'crypto++/cryptlib.h file not found'
I think it has something to do with me not having the correct components installed or not referenced correctly within XCode. Should I be linking against a static library to get these headers? Is there a project setting I need to change to search in a specific directory to find these files?
If you can help, thank you very much.
Xcode cannot find the above headers. This is because they are not in the include path. This is most likely to one of two reasons.
You don't have the above libraries installed.
You haven't added the correct path to your build config (like /opt/local/include if you are using macports)
Solutions to try:
Make sure that you actually installed Curl and cryptopp (crypto++) (i.e. compiled them yourself or used a package manager like macports or brew)
Make sure that your build includes the paths to these files (Look at the "header search paths" in xcode project settings
PS. Do not think about linking or such - this has nothing to do with it. You will run into these problems after you've actually compiled the code - i.e. in the linking phase :)