LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-21-2005, 01:54 AM   #1
velan
Member
 
Registered: Apr 2004
Posts: 89

Rep: Reputation: 15
Windows programs in gcc


How do I compile Windows C code in gcc linux? it's basically a Windows socket progframming code (includes winsock.h. etc). I forget the option which we have to give to gcc, so that the program will be compiled successfully. help me out pls ...
 
Old 03-21-2005, 05:12 AM   #2
ichrispa
Member
 
Registered: Mar 2005
Location: Dresden, Germany
Distribution: OpenSuse 11.2/3, Debian 5.0 , Debian 1.3.1, OpenBSD
Posts: 277

Rep: Reputation: 32
This might just get to be a problem...

I was trying to write network programs under wi... windo..., god forgive me, windows using djgpp but there is just single glitch - windows uses .lib s, linux .a . In theory you have to link your program to something looking like libwinsock.a - but that does not exist.

The easiest way to do this is to change the headers one by one to whatever equivalent exists in linux (socket.h, types, in.h, arpa.h etc.). Its a lot of work to do. If however you have found a way to reuse windows libraries through linux then what you need is this:

gcc your_sourc_efile -o name_of_output -l library_in_searchpath

good luck
 
Old 03-21-2005, 08:26 AM   #3
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
If you are using Cygwin, I believe you can use something like the -mwin parameter.

Windows itself doesn't use .lib files. Some Windows compilers like MS VC++ use .lib files. Cygwin's compiler also uses .a, and .la, and sometimes .dll.a...

Anyway, what sort of errors do you get? If you still have problems, give some more specific info, like what Windows GNU compiler you are using. (Cygwin's, Mingw, etc.)

Edit: Just noticed you are trying to compile a Windows program in Linux using gcc, not trying to use a Window's version of gcc. I don't have any sort of experience with that, but you'd need some form of cross-compiler.

Last edited by deiussum; 03-21-2005 at 08:30 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"gcc linker" does not link C++ programs ( gxx_personality undefined ?) bahramH Programming 9 12-25-2009 01:38 PM
can't compile simple C++ programs on Suse 9.1 after installing gcc cyclebain Linux - Software 9 07-04-2007 08:04 AM
Problem compiling programs using ncurses library (gcc 3.2.2 and RH9 default inst.) jclark7777 Linux - Newbie 1 07-20-2004 01:59 PM
how to compile c++ programs with gcc nimra Programming 7 05-17-2004 07:08 AM
Upgraded GCC; now many programs don't work Zoombie Linux - Software 13 02-24-2004 06:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration