Compiling a program that requires both python.h and cl.h - c

I'm trying to compile a program that uses both python.h and cl.h using: gcc -Wall -I/usr/include/python2.7 -lpython2.7 -I/home/arm/bin/c/hashcat/deps/OpenCL-Headers/CL -lOpenCL cpu_md4.c -o cpu_md4, however when I run this I get the following:
arm#arm-Aspire-5733Z:~/bin/python/dagon/bin/attacks/cpu_attack$ gcc -Wall -I/usr/include/python2.7 -lpython2.7 -I/home/arm/bin/c/hashcat/deps/OpenCL-Headers/CL -lOpenCL cpu_md4.c -o cpu_md4
In file included from types.h:889:0,
from cpu_md4.c:10:
ext_OpenCL.h:15:19: fatal error: CL/cl.h: No such file or directory
#include <CL/cl.h>
^
compilation terminated.
arm#arm-Aspire-5733Z:~/bin/python/dagon/bin/attacks/cpu_attack$
How I got the cl.h directory was doing this:
arm#arm-Aspire-5733Z:~/bin/python/dagon/bin/attacks/cpu_attack$ find / -iname cl.h 2>/dev/null
/home/arm/bin/c/hashcat/deps/OpenCL-Headers/CL/cl.h
How can I compile this application using the header files that I already have?

Related

cygwin compile C source with Gcc and set include in different place

hi i want compile in cygwin a C source, but i want include also library,the library is placed in another location then prog but i dont know why it not want recongnize that.
I used this code:
gcc -c -fpic -O2 stringregexp.c -I /../../language/include
or
gcc -c -fpic -O2 stringregexp.c -I /cygdrive/c/ring/language/include
error
ring.h:106:18: fatal error: ring_ext.h: No such file or directory
106 | #include "ring_ext.h"
thanks

Compilation error on linux server (C project)

I need some help.
I worked on a C project locally and it ran perfect with no issues at all.
Then I moved my whole project files to a linux server (using Bitwise) and ran it using the following command:
gcc -g -std=c99 -Wall -pedantic-errors -Werror -DNDEBUG main.c map.c map.h utilities.c
utilities.h election.c election.h extended_map.c extended_map.h test_utilities.h -o outmap
and again everything worked as expected.
Now, I want to replace my version of test_utilities.h with the version saved on that server, so I opened main.c (which is the only file to include test_utilities.h and replaced:
#include "test_utilities.h"
with
#include "~mtm/public/1920b/ex1/test_utilities.h"
But the terminal shows me the following error:
gcc: error: test_utilities.h: No such file or directory
-bash-4.2$
As suggested I changed it to
gcc -g -std=c99 -Wall -pedantic-errors -Werror -DNDEBUG main.c map.c map.h utilities.c utilities.h election.c election.h extended_map.c extended_map.h test_utilities.h -o outmap -I ~mtm/public/1920b/ex1/
But still I get the following:
gcc: error: test_utilities.h: No such file or directory
update2: (I was requested to remove .h files so now I got)
gcc -g -std=c99 -Wall -pedantic-errors -Werror -DNDEBUG main.c map.c utilities.c election.c extended_map.c -o outmap
Writing ~mtm to refer to the home directory of user mtm is a shortcut that your shell understands. It isn't something that the C preprocessor understands. So you'll have to spell it out as /home/mtm (or wherever mtm's home directory is located) instead of ~mtm.
That said, a better way would be to just leave it as "test_utilities.h" and instead adjust the include path of the compiler (specified via -I when invoking the compiler) to include ~mtm/public/1920b/ex1/.
You also shouldn't specfiy test_utilities.h as an argument to the compiler. In fact none of the header files should be passed as arguments to the compiler.

GCC on Mojave: The compiler cannot read the includes at -I /opt/X11/include/X11

Trying to compile with GCC on Mojave and am getting an error.
gcc -g -ansi -c test_scroll_images_3x.c -I /opt/X11/include/X11
test_scroll_images_3x.c:17:11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
^~~~~~~~~~~~
1 error generated.
I have several subroutines like this, and all have the same problem.

Compiling C code that uses R libraries in Netbeans

I've been having trouble debugging some C code that I'm writing as part of an R package. The code compiles and executes when I use R CMD SHLIB from the Windows console (i.e. cmd.exe):
>R CMD SHLIB MaximumAgreementForest.c
gcc -m64 -I"C:/PROGRA~1/R/R-32~1.4RE/include" -DNDEBUG -I"d:/RCompile/r-compiling/local/local323/include" -O2 -Wall -std=gnu99 -mtune=core2 -c MaximumAgreementForest.c -o MaximumAgreementForest.o
gcc -m64 -shared -s -static-libgcc -o MaximumAgreementForest.dll tmp.def MaximumAgreementForest.o -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/PROGRA~1/R/R-32~1.4RE/bin/x64 -lR
The script also built correctly in Netbeans until I started using the functions R_alloc and C_alloc from the R libraries. Now it doesn't seem to be able to find the definitions of a number of R-specific functions. When I attempt to build the project in Netbeans the console lists the following:
cd 'C:\Work\Fun\implied_weight\MAF'
C:\MinGW\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Work/Fun/implied_weight/MAF'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/libMAF.dll
make.exe[2]: Entering directory `/c/Work/Fun/implied_weight/MAF'
mkdir -p build/Debug/MinGW-Windows/_ext/5c0
rm -f "build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o.d"
gcc -DDEBUG -O2 -Wall -mtune=core2 -c -g -Wall -I/C/Program\ Files/R/R-3.2.4revised/include -MMD -MP -MF "build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o.d" -o build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o ../MaximumAgreementForest.c
mkdir -p dist/Debug/MinGW-Windows
gcc -DDEBUG -O2 -Wall -mtune=core2 -o dist/Debug/MinGW-Windows/libMAF.dll build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o -L/C/Program\ Files/R -L/C/Program\ Files/R/R-3.2.4revised/library -shared
build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o: In function `forest_new':
C:\Work\Fun\implied_weight\MAF/../MaximumAgreementForest.c:37: undefined reference to `R_alloc'
build/Debug/MinGW-Windows/_ext/5c0/MaximumAgreementForest.o: In function `forest_plant':
C:\Work\Fun\implied_weight\MAF/../MaximumAgreementForest.c:55: undefined reference to `S_alloc'
[...]
C:\Work\Fun\implied_weight\MAF/../MaximumAgreementForest.c:515: undefined reference to `R_chk_free'
collect2.exe: error: ld returned 1 exit status
My script, a single .c file, contains the lines
#define USE_RINTERNALS
#include <R.h> // which itself #includes R_ext/Memory, R_ext Printf
#include <R_ext/Print.h>
#include <R_ext/Memory.h>
#include <Rinternals.h>
Figuring that Netbeans is failing to point to the relevant libraries, I have tried adding and removing C:/Program Files/R/R-3.2.4revised/include and C:/Program Files/R/R-3.2.4revised/bin/x64 at File→Project Properties→General→Source folders, to no effect.
Under File→Project Properties→Build→C compiler, I have included C:/Program Files/R/R-3.2.4revised/include.
When I add C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll to Build→Linker→Libraries→Libraries, via the Add Library... option, I receive the error c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lR, and the linker exits without (before?) complaining about the undefined references.
When I subsequently add "C:/Program Files/R/R-3.2.4revised/bin/x64/", which is already in by System PATH, to Build→Linker→Additional Library Directories, the compiler fails with the message C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll: file not recognized: File format not recognized
What am I missing... how can I point Netbeans to the relevant R libraries?
The File format not recognized error is encountered when a 32-bit compiler tries to load to a 64-bit .dll (or vice-versa). Changing the path
C:/Program Files/R/R-3.2.4revised/bin/x64/R.dll
to
C:/Program Files/R/R-3.2.4revised/bin/i386/R.dll
resolved the problem.

How to include an archive file in your c code

I'm making an archive file, which I am then trying to include in my code, but when I try to #include 'libutils.h', I get an error:
src/indexer.h:8:10: fatal error: 'libutils.h' file not found
#include "libutils.h"
my make command is:
gcc -g -std=c11 -Wall -pedantic -o indexer src/indexer.c -L. -lutils.a
my file structure is:
Indexer/
libsutil.a obj/ src/ makefile
obj/
web.o list.o hashtable.o //These are the files in the archive file
src/
web.c web.h list.c list.h hashtable.c hashtable.h indexer.c indexer.h
You don't need to include anything, remove the
#include "libutils.h"
from the .c file, and your compilation command will be
gcc -g -std=c11 -Wall -pedantic -o indexer src/indexer.c -L. -lutils

Resources