Im trying to compile some files with this given gcc command on a server cluster through Mac terminal:
gcc -o driver -std=c11 -Wall -W -ggdb3 driver.c ASMParser.c ParseResult.c Generate.o Grader.o
And get this error:
/usr/bin/ld:Grader.o: file format not recognized; treating as linker script
/usr/bin/ld:Grader.o:1: syntax error
collect2: error: ld returned 1 exit status
but its not very helpful considering Grader.o is a file I didn't even modify, it was provided by the teacher.
Any help on how to fix this? I have compiled it successfully using that gcc command before but after I added a few more implementation details in ASMParser.c it started giving me this error. Im expecting it to create a file called "driver" that I can run like this:
./driver "test file" "results.txt"
Related
Goal:
To correctly install and use lexbor on CentOS 7.
Current output:
When I go to compile a program using lexbor with the command gcc example.c -liblexbor -std=c99 -o example on CentOS 7, the following error is received:
[user#localhost]$ gcc example.c -liblexbor -std=c99 -o example
/usr/bin/ld: cannot find -liblexbor
collect2: error: ld returned 1 exit status
Details:
I installed lexbor for CentOS 7 following the instructions found at this link for CentOS 7. It seems that the linker cannot find the library. I ran the command ldconfig -p to find the path of the lexbor lib, which returned:
liblexbor.so.2 (libc6,x86-64) => /lib64/liblexbor.so.2
With the path found, I then ran the following two commands I recompiled using the same compilation command as the one seen above, but the same error message was shown:
[user#localhost]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib64/liblexbor.so.2
[user#localhost]$ sudo ldconfig
I then tried a different approach to see if I could solve this issue by embedding the path into the compilation command, but this resulted in the same output:
gcc -L/lib64/ -liblexbor -std=c99 example.c -o example
Please note: before deciding to post this question, I consulted the following resources:
usr/bin/ld: cannot find -l<nameOfTheLibrary>
https://askubuntu.com/questions/1007591/usr-bin-ld-cannot-find-lopencl
Summary question:
q1. How can this error be solved when trying to compile a C program using lexbor on CentOS 7?
You're specifying the library name incorrectly. For a given library file named liblibrary.so, the correct option is -l library. So you need to compile like this:
gcc example.c -llexbor -std=c99 -o example
I'm trying to run a simple code that includes the fftw library. I know the code is right as it is provided as a test code by the authors. This is what I typed during compilation:
gcc my file.c -L/home/ankit/Desktop/fftw-3.3.6-pl2/lib/
-I/home/ankit/Desktop/fftw-3.3.6-pl2/include/ -lfftw -lm
I get the errors:
myfile.c: (.Text+0x2c):. undefined reference to 'fftw_plan_dft_2d'
collect2: ld returned 1 exit status
It wasn't a linking problem, installation was faulty and I had to use 'sudo make install' to get the permission for the installation to be successful. I could link it with 'gcc test.c -lfftw3 -lm' after. Thanks for your suggestions!
Hey I am currently learning C and tried to divide my code in multiple files. But when it comes to compile the project, I got this error :
mingw32-gcc.exe -Wall -g -c D:\IDE\CodeBlocks\Projects\Tuto\main.c -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\Tuto.exe obj\Debug\dico.o dico.h.gch obj\Debug\main.o
dico.h.gch: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
I tried to clean and/or rebuild my project but nothing goes through this issue. Can anyone help me please ??
dico.h.gch is a precompiled header. You aren't supposed to link it with your objects. Remove it from the line that creates Tuto.exe.
I am attempting to compile a C program with multiple files on window platform. However, when I make it, errors are occurred. I have already tried to modify command in makefile but still could not fix it.
This is my GCC command:
gcc -o "SYSMONTR" $(OBJPATH)/chkdsksp ../chkdsksp.c -g -I"$(DB2PATH)/include" -I"$(MYLIBDIR)" $(MYIQDIR)/iqclilib.a $(OBJPATH)/icrou.a -lc -ldb2 -lnsl -L"$(DB2PATH)/lib"
This is result:
gcc -o "SYSMONTR" ../../iLINKOBJ/chkdsksp ../chkdsksp.c -g -I"C:/Program Files/IBM/SQLLIB/include" -I"../../iLINKCLIB" ../../iLINKIQOBJ/iqclilib.a ../../iLINKOBJ/icrou.a -lc -ldb2 -lnsl -L"C:/Program Files/IBM/SQLLIB/lib"
../../iLINKOBJ/chkdsksp: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
makefile:49: recipe for target `SYSMONTR' failed
make: *** [SYSMONTR] Error 1
What could cause such error and what should I do with it? Using cygwin on Window (IDE: Eclipse).
Any supports will be appreciated.
If chkdsksp is an object file built by another team to run on AIX, you cannot expect it to function -- or even be recognized by your compiler -- on Cygwin. You must contact that team and get a) the source code or b) a version of the object file compiled for your platform (and tested).
I'm trying to compile a makefile which includes the following line:
gcc -I. -I/home/usr/Documents/MTV/include -ggdb3 -Wall -O2 -o ascii2bin.c \
-L. -L../lib -lmatrix -lseq_io -lpic -lm
And this is what I get:
../lib/libmatrix.a: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Any idea on what might happen to libmatrix.a? How can I read what's inside libmatrix.a? I tried using the 'ar -t' command, but it also says file format not recognized.
The project was compiled on Cygwin before by others, and now I'm using ubuntu gcc to try to redo it, could this be the problem?
A library file built for cygwin will not work on linux.
The library itself must be recompiled from source to match the details (ABI, dynamic system library dependencies, etc) of the system on which it is intended to be used.
Cygwin tries to be source compatible with Linux, so if you have the source rebuilding may be straightforward. But it is not binary-compatible, and libraries are basically binary building blocks with metadata to permit linking them together.