I'm having some issues getting a CHIP-8 interpreter to compile.
Upon pressing ctrl+f9 to compile I am met by a message saying "Build ended with errors. Continue?".
Checking the build log reveals the following error: C:/Workspace/****/****/main.c:4:17: fatal error: sdl.h: No such file or directory
I have tried copying SDL.h into the source directory, that did not work.
I tried making a directory in source called "SDL" (src/SDL/SDL.h), did not work.
I also tried making a folder next to src, (SDL/SDL.h). That did not work either.
After that I tried #include <.SDL.h>, #include <.sdl.h>, #include <.SDL.dll> and #include <.sdl.dll> (ignore the period after the "<" symbol)
I have also tried copying over the files for SDL version 1.2.15 and SDL version 2.0.3. That did work either.
Am I doing something fundamentally wrong?
How do I get this to compile?
You have to say your compiler where sdl.h lives, with -I/path/to/sdl switch on gcc or filling Include Path in msvc
(don't move it, as it (sdl.h) will probably needs other header files)
Here's a step-by-step on how to get SDL1.2.5 working with codelite:
Download the "Development Libraries" from here
Extract the tar.gz file contents to a directory. For eg: C:\mysdl
In codelite, right-click over the project's name in the "Workspace View"
From the context menu, select "Settings..."
The 'Project Settings' dialog will appear.
In the "configuration Type" choose "Debug" or "Release", based on your requirements. You can also, do the following steps for both Debug and Release.
Go to "Compiler" tab
In "Additional Search Path", add the path where all the sdl include files are. For eg: C:\mysdl\include
Go to "Linker" tab
In "Library Path", add you lib path eg: C:\mysdl\lib\
In the "Options" append -lSDL -lSDLmain -lmingw32 -mwindows(case-matters)
Copy C:\mysdl\bin\SDL.dll to C:\WINDOWS\SYSTEM32 or if 64-bit C:\Windows\SysWOW64
When including headers you must use #include "SDL\SDL.h" or #include "SDL.h" depending on how you configure your directory structure.
Related
I have a some code files and a directory with some header files in sub-directories, structured like this:
code\my_file.c
code2\other_file.c
headers
where headers contains the sub-directories openssl, curl.
When I use #include <openssl/evp.h> inside my_file.c it fails with:
fatal error: openssl/evp.h: No such file or directory
However, it works from other_file.c
Additionally, when I include the full path #include "../headers/openssl/evp.h it works fine.
Is there a reason one file in my project knows to find the openssl dir and the other doesn't?
Using Eclipse
I tried changing properties, by adding an include path:
but it didn't work...
This what fixed it for me but if someone has another answer, I'd love to hear it
So, it turns out I just needed to do the exact same thing in the GNU C++ tab also:
I was originally following this tutorial: http://www.opengl-tutorial.org/miscellaneous/building-your-own-c-application/
just after about half way down, from where it says "Adding a source file in a project"
I created from this my CMakeLists.txt file as so:
cmake_minimum_required (VERSION 2.6)
project (Cube_Project)
find_package(OpenGL REQUIRED)
add_executable(Cube
main.cpp
)
include_directories(
external/glfw-2.7.6/include/
external/glm-0.9.4.0/
external/glew-1.9.0/include/
.
)
set(ALL_LIBS
${OPENGL_LIBRARY}
GLFW_276
GLEW_190
)
target_link_libraries(Cube
${ALL_LIBS}
)
but when I generate the project, I get this error:
ld: library not found for -lGLFW_276
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
I think maybe I'm not using the right names in the set(....) section? My three libs are in a folder called external, which is the top level of the project (i.e. CMakeLists is also here).
I put a zip of the project if anyone wants to take a look at the folder layout of output XCode project structure: http://heather.sh/OpenGL_Project.zip
Thanks,
The library is not in the linker's library search path.
The target_link_libraries command is is very straightforward: It simply passes on all of its arguments to the linker without bothering whether any of those libraries actually exist.
In your case, the GLFW_276 library is missing (and possibly the GLEW_190 as well, since the error occurs before that one is being processed). Make sure the library is actually installed on your system and its filename actually matches the name you use here (eg. libGLFW_276.so).
Once you verify that you have the required file, you need to make sure that the linker is able to find it. If the file is not located in one of the standard directories, use either link_directories to add its location to the search path, or find_library to obtain the full path to the library file, which can then be given to target_link_libraries.
I am working on a project which requires me to download and use this. Inside the downloaded folder, when extracted I am presented with three things:
A folder called "include"
A folder called "src"
A file called "Makefile"
After some research, I found out that I have to navigate to the directory which contains these files, and just type in the command make.
It seemed to install the library in my system. So I tried a sample bit of code which should use the library:
csp_conn_t * conn;
csp_packet_t * packet;
csp_socket_t * socket = csp_socket(0);
csp_bind(socket, PORT_4);
csp_listen(socket, MAX_CONNS_IN_Q);
while(1) {
conn = csp_accept(socket, TIMEOUT_MAX);
packet = csp_read(conn, TIMEOUT_NONE);
printf(ā%S\r\nā, packet->data);
csp_buffer_free(packet);
csp_close(conn);
}
That's all that was given for the sample server end of the code. So I decided to add these to the top:
#include <csp.h>
#include <csp_buffer.h>
#include <csp_config.h>
#include <csp_endian.h>
#include <csp_interface.h>
#include <csp_platorm.h>
Thinking I was on the right track, I tried to compile the code with gcc, but I was given this error:
csptest_server.c:1: fatal error: csp.h: No such file or directory
compilation terminated.
I thought I may not have installed the library correctly after all, but to make sure, I found out I could check by running this command, and getting this result:
find /usr -iname csp.h
/usr/src/linux-headers-2.6.35-28-generic/include/config/snd/sb16/csp.h
/usr/src/linux-headers-2.6.35-22-generic/include/config/snd/sb16/csp.h
So it seems like the csp.h is installed, maybe I am referencing it incorrectly in the header include line? Any insight? Thanks a lot.
The make command is probably only building the library, but not installing it. You could try sudo make install. This is the "common" method, but I recommend you to check the library's documentation, if any.
The sudo command is only necessary if you have no permissions to write the system's include and library directories, which may be your case.
Another possibility (instead of installing the library) is telling GCC the location of the library's source code and generated binaries (by means of the -I and -L options of the gcc command.
That Makefile will not install anything, just translate the source into a binary format.
The csp.h in the Linux kernel has nothing to do with your project, it's just a naming collision, likely to happen with three letter names.
In your case, I would presume you need to add the include directory to the compilation flags for your server, like gcc -I/path/to/csp/include/csp csptest_server.c.
(Next, you'll run into linker errors because you'll also want to specify -L/path/to/csp -lcsp so that the linker can find the binary code to link to.)
Vim is pretty smart when it comes to C, so if one inserts a bogus header file such as #include <stdioo.h>, it complains by bringing up a location list with the following error:
foo.c:1|20| fatal error: stdioo.h: No such file or directory
|| compilation terminated.
Which is great, but for whatever reason, I get the same error when including the <mpi.h> header file. I know this is a vim problem b/c I can compile and execute the program with mpicc and mpiexec, respectively. Besides it being extremely irritating having it pop up every time I save the file, all syntax errors are ignored when this happens.
Is there any way to instruct vim to ignore this header file, or at least all the header files?
WHERE on your filesystem is the <mpi.h> file located?
Often it's one level down, such as /usr/include/mpi/mpi.h and would require <mpi/mpi.h> to access it.
You may need to add another directory path to the -I option list of your compiler, or add the directory path to VIM's path option variable
:help 'path
Will get you started on the VIM side, you'll need to look up how to add options to your current setup, no idea if you're using cmake, make, visual something, netclipse or whatever.
But a simple 'locate mpi.h' would be the place to start, since you know it's there.
You said "pop-up" ... are you using syntastic or such? Again, finding the proper path would help there too. Evidently mpicc knows the proper path to the include files, you just need to tell VIM. (via the 'path' option)
I have added some source (header files) in a common folder (..\shared\abc) and my code file from another folder (..\src\xyz) has #include <abc/../foo.hpp>. I get this error:
Cannot open Source file error
I can fix that by giving absolute path but that change needs to be done at many place. What should I see to fix this?
Using VC9 nmake to compile code. This is a Makefile based project.
If the included files are from some library your code is using, you'll want to specify the include path with a compiler option. For the Visual C++ compiler the command-line option to specify additional include directories is /I, e.g.:
cl /I ..\shared foo.cpp
You'll need to modify the compiler options in your Makefile accordingly.