linking problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

linking problem

Alessandro Antonello
Hi, all.

I already made a lot of static libraries with mingw-gcc compiler. I
also made some DLLs to run on Windows. Now I am stuck in linking a
little "DOS" application. In this case, I have two questions that I
need some help:
1th: There is a way to not link with libmsvcrt.a? I am just using
standard C functions and I don't want this garbage in my executable.
2ht: The linker keep me saying that it cannot find "__main" (undefined
reference). I am just linking with libgcc and libmsvcrt. The
"-nostdlibs" is in my command line because I like to learn what is in
use when I am making thinks. What am I missing?

So, I know that this is a newbie question but I would appreciate some
help, very much.

--
Alessandro Antonello

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
Reply | Threaded
Open this post in threaded view
|

Re: linking problem

Greg Chicares
On 2008-12-02 15:25Z, Alessandro Antonello wrote:
>
> I already made a lot of static libraries with mingw-gcc compiler. I
> also made some DLLs to run on Windows. Now I am stuck in linking a
> little "DOS" application.

If you mean a 32-bit windows console application, okay.

If you mean a program to run on the 16-bit DOS operating system,
then what you want is djgpp, not MinGW.

> 1th: There is a way to not link with libmsvcrt.a? I am just using
> standard C functions and I don't want this garbage in my executable.

Isn't that the import library for the dll that implements the
standard C library functions you want to use?

> 2ht: The linker keep me saying that it cannot find "__main" (undefined
> reference). I am just linking with libgcc and libmsvcrt. The
> "-nostdlibs" is in my command line because I like to learn what is in
> use when I am making thinks. What am I missing?

First, take the path of least resistance, and use the linker in
the usual way: invoke it as 'gcc', and don't add unusual flags
like '-nostdlibs'. Then add the flag that makes the linker tell
you everything it's doing. Then you can experiment with other
flags, and compare the output to something that is known to work.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
Reply | Threaded
Open this post in threaded view
|

Re: linking problem

JonY-2
In reply to this post by Alessandro Antonello
On 12/2/2008 23:25, Alessandro Antonello wrote:
> Hi, all.
>
> I already made a lot of static libraries with mingw-gcc compiler. I
> also made some DLLs to run on Windows. Now I am stuck in linking a
> little "DOS" application. In this case, I have two questions that I
> need some help:
> 1th: There is a way to not link with libmsvcrt.a? I am just using
> standard C functions and I don't want this garbage in my executable.

Garbage?  DOS application? MinGW does not do DOS. The C functions come
from libmsvcrt.a, an import lib for msvcrt.dll.

> 2ht: The linker keep me saying that it cannot find "__main" (undefined
> reference). I am just linking with libgcc and libmsvcrt. The
> "-nostdlibs" is in my command line because I like to learn what is in
> use when I am making thinks. What am I missing?
>

Its at libmingw32.a. You might just want to link with "gcc -v" to see
all the details.

> So, I know that this is a newbie question but I would appreciate some
> help, very much.
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
Reply | Threaded
Open this post in threaded view
|

Re: linking problem

Brian Dessent
In reply to this post by Alessandro Antonello
Alessandro Antonello wrote:

> 1th: There is a way to not link with libmsvcrt.a? I am just using
> standard C functions and I don't want this garbage in my executable.

And what do you think it is that implements those standard C functions
if not MSVCRT?  You're free to not link with MSVCRT if you want to stick
to entirely Win32 or NT APIs, but you can't complain about link errors
for ANSI C functions if you do.

> 2ht: The linker keep me saying that it cannot find "__main" (undefined
> reference). I am just linking with libgcc and libmsvcrt. The
> "-nostdlibs" is in my command line because I like to learn what is in
> use when I am making thinks. What am I missing?

You're missing -lmingw32.  These libraries are there by default for a
reason. You can't remove them and expect things to continue to work.
__main() is a function whose purpose is to run global constructors and
to register global destructors to be run at exit.  gcc emits a call to
it in the prologue of main().

Brian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
Reply | Threaded
Open this post in threaded view
|

Re: linking problem

Alessandro Antonello
In reply to this post by Greg Chicares
Hi Greg.

This really helped. Thanks a lot.


2008/12/2 Greg Chicares <[hidden email]>:

> On 2008-12-02 15:25Z, Alessandro Antonello wrote:
>>
>> I already made a lot of static libraries with mingw-gcc compiler. I
>> also made some DLLs to run on Windows. Now I am stuck in linking a
>> little "DOS" application.
>
> If you mean a 32-bit windows console application, okay.
>
> If you mean a program to run on the 16-bit DOS operating system,
> then what you want is djgpp, not MinGW.
>
>> 1th: There is a way to not link with libmsvcrt.a? I am just using
>> standard C functions and I don't want this garbage in my executable.
>
> Isn't that the import library for the dll that implements the
> standard C library functions you want to use?
>
>> 2ht: The linker keep me saying that it cannot find "__main" (undefined
>> reference). I am just linking with libgcc and libmsvcrt. The
>> "-nostdlibs" is in my command line because I like to learn what is in
>> use when I am making thinks. What am I missing?
>
> First, take the path of least resistance, and use the linker in
> the usual way: invoke it as 'gcc', and don't add unusual flags
> like '-nostdlibs'. Then add the flag that makes the linker tell
> you everything it's doing. Then you can experiment with other
> flags, and compare the output to something that is known to work.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
> _______________________________________________
> This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.
>



--
Alessandro Antonello

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.