I am trying to compile a hello world program using MinGW on Windows 10. I am compiling from the command prompt with just:
gcc hlw.c
However, I get the following error:
d:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpthread
collect2.exe: error: ld returned 1 exit status
Obviously, my program does not use threads; it should just print one line to the output. What is going wrong?
Related
I'm very new at coding. I dowloaded VSCode to practice C.`I copied a line of code from the internet, the "Hello World". As I try to run it, my terminal shows this:
none
C:\Users\Selene_514\Desktop\C CPP>cd "c:\Users\Selene_514\Desktop\C CPP" && gcc hello.c -o hello && "c:\Users\Selene_514\Desktop\C CPP"hello
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status.
I installed MinGW and changed the environment path properly. What should I do?
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"
I get the following error while compiling xpdf using make. I've tried using the command:
LIBS=-lm make
However, it doesn't work. I know the problem is that the c compiler cannot recognise the math symbols in the source code because the math library is not available to it, but I don't know how to fix it.
[ 71%] Linking CXX executable pdftohtml
/usr/bin/ld: CMakeFiles/xpdf_objs.dir/Gfx.cc.o: undefined reference to symbol 'acos##GLIBC_2.2.5'
//usr/lib64/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [xpdf/CMakeFiles/pdftohtml.dir/build.make:219: xpdf/pdftohtml] Error 1
make[1]: *** [CMakeFiles/Makefile2:428: xpdf/CMakeFiles/pdftohtml.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
I have put my Makefile and makeLists.txt on pastebin for more information
I realised I had to use the g++ compiler instead of gcc after reading the man page for gcc which stated:
The usual way to run GCC is to run the executable called gcc, or
machine-gcc when cross-compiling, or machine-gcc-version to run a
specific
version of GCC. When you compile C++ programs, you should invoke GCC as g++ instead.
I am a beginner in both linux and openwrt. Sorry if this is a stupid question.
I am following this tutorial : https://downloads.openwrt.org/docs/eclipse.pdf
Chip : MT7620
Toolchain Prefix : mipsel-openwrt-linux-
Toolchain Path : /ligo/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-5.3.0_musl-1.1.14
Code:
#include <stdio.h>
void main()
{
printf("Hello World");
}
Error:
**** Build of configuration Debug for project hello ****
make all
Building target: hello
Invoking: Cross GCC Linker
mipsel-openwrt-linux-gcc -L/ligo/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-5.3.0_musl-1.1.14/lib -o"hello" ./main.o
mipsel-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
mipsel-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
/ligo/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-5.3.0_musl-1.1.14/lib/gcc/mipsel-openwrt-linux-musl/5.3.0/../../../../mipsel-openwrt-linux-musl/lib/crt1.o: In function `_start_c':
/ligo/openwrt/build_dir/toolchain-mipsel_24kec+dsp_gcc-5.3.0_musl-1.1.14/musl-1.1.14/crt/crt1.c:17: undefined reference to `main'
/ligo/openwrt/build_dir/toolchain-mipsel_24kec+dsp_gcc-5.3.0_musl-1.1.14/musl-1.1.14/crt/crt1.c:17: undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [hello] Error 1
add the following 2 lines at the end of bashrc
export PATH=$PATH:~/openwrt/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin
export STAGING_DIR=~/openwrt/staging_dir
source ~/.bashrc
To open/create the bashrc you can execute
sudo gedit ~/.bashrc
Well I feel stupid when I have to figure this problem which happens too often.
I get the above error when I forget to save the file that contains main() it gives this error since the file is empty until you save it.
These instructions tell how to automatically save all the modified files when you kick off a build Save before build Keep this set and you won't see this again.
If you don't have the path to the toolchain set in eclipse, it never even finds a compiler, assembler or linker so it can not produce the error given. The warnings about STAGING_DIR are harmless in this case.
I'm trying to compile an external Matlab function C code to use the function with my Matlab (2013a). When I type "make" I get an error "mex: command not found". How can I successfully compile the function? I'm using OS X 10.9.
To be more specific, I'm trying to install the function SVMStruct (from http://www.robots.ox.ac.uk/~vedaldi/code/svm-struct-matlab.html#ssvm.download) but lack of mex command on my mac prevents from doing so. Here is the complete error message
mex -largeArrayDims - CFLAGS='$CFLAGS -Wall' LDFLAGS='$LDFLAGS ' -outdir "build//" -c > "svm_struct_api.c"
/bin/sh: mex: command not found
make: *** [build//svm_struct_api.o] Error 127