Thread: Problems compiling with MinGW

  1. #1
    Registered User
    Join Date
    Sep 2016
    Posts
    2

    Problems compiling with MinGW

    I have been struggling to get simple code to compile on Win7 or Win10. I installed MinGW graphical install for 'mingw32-base', 'mingw32-gcc-g++', 'mingw32-gcc-obj', and 'msys-base'. I am just needing a c compiler for now, so I'm assuming that just installing 'mingw32-gcc-g++' should be all I need. After installing I added C:\MinGW\bin to my path in windows. Not sure what else I'm missing here.

    My code:

    Code:
    #include<stdio.h>
    
    int main(){char *c="int main(){char *c=%c%s%c;printf(c,34,c,34);}";printf(c,34,c,34);}
    My Error:

    Code:
    c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lpthread
    collect2.exe: error: ld returned 1 exit status
    From what I have read, this error is happening because its not finding the libraries?

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    cannot find -lpthread
    Why are you asking to compile with the pthread library? It's completely unnecessary for this program.
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Sep 2016
    Posts
    2
    I didn't realize it was asking that. I'm doing this through cmd, so I just use 'gcc test.c -o test'. I feel like I'm missing something obvious here.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    This behavior is strange. There may be some problem with the binaries you've downloaded. Why don't you use an IDE instead? Codeblocks, for example, can be downloaded bundled with 32-bit MinGW( somewhat dated, but better than nothing ).
    Download binary
    Devoted my life to programming...

  5. #5
    Guest
    Guest
    I haven't used Windows in a while but I had good success with mingw-w64 builds. It's up to date and offers different versions depending on your needs.

    For instance this might be what you want. Just extract and add the bin directory to the PATH variable, as you did before. No installer.

    I'm of the opinion that an IDE hinders learning when starting out. Manual compilation (as you do) helps one learn about the things beyond the language syntax, that are nonetheless important to know.
    Last edited by Guest; 09-01-2016 at 10:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling with GTK+ / MinGW
    By Sotos in forum C Programming
    Replies: 9
    Last Post: 06-05-2015, 01:09 PM
  2. Compiling gcc for Windows (MinGW)
    By carrotcake1029 in forum Windows Programming
    Replies: 0
    Last Post: 03-14-2010, 12:11 AM
  3. MinGW Compiling Issue
    By gesangbaer in forum C++ Programming
    Replies: 3
    Last Post: 12-10-2009, 09:41 PM
  4. Compiling to an exe with mingw...
    By Blackroot in forum Tech Board
    Replies: 7
    Last Post: 08-26-2006, 04:36 AM
  5. Compiling Resources In MinGW
    By Okiesmokie in forum C++ Programming
    Replies: 2
    Last Post: 03-06-2002, 04:16 PM

Tags for this Thread