Compile static with gcc? Help!

Hey!

Im currently writing some small tools with OpenGL, Im also using some TK’s to build up my GUI’s.

Im currently using the compile command:

“gcc -o app app.cpp -lGL -lm”

… but how do I compile if I want to make a “static” app? So that I can share it with other people without sending lots of libraries too…Shortly, I want a standalone tool that doesnt require lots of dynamic linked libraries…

Thanks!

/Joda

Is that a good idea,especially with opengl libs?Wouldn’t static linking mean that you’d link against your libs?If the user had a different card it wouldn’t run,would it?Besides opengl is now part of X so it should be available on most boxes.

[This message has been edited by zen (edited 10-19-2002).]

Hey Zen!

Thanks for your reply! You see Im using some tookit’s to build my GUI which every X system doesnt have. You’re right about the openGL thing. But how do I compile my gui libs static and my openGL libs not static?

Thanks!

  • Joda

Originally posted by zen:
[b]Is that a good idea,especially with opengl libs?Wouldn’t static linking mean that you’d link against your libs?If the user had a different card it wouldn’t run,would it?Besides opengl is now part of X so it should be available on most boxes.

[This message has been edited by zen (edited 10-19-2002).][/b]

I actually have no idea.That’s why I didn’t mention it in the previous post .But I did do a quick google search on ‘static linking’ and came up with a page with the following:

gcc - surround the libraries you wish to link statically with -static and -dynamic (in that order). For example:
% gcc -o foo foo.o bar.o -L/s/X11R6.3-1/lib -R/s/X11R6.3-1/lib
-static -lX11 -lXext -dynamic -lXt -lSM -lsocket -lnsl

If it doesn’t work you can:
1)do man gcc and look for ‘static’ or ‘dynamic’
2)do a more thorough google search yourself
3)hope someone else will post

In general though(no flaming intended) you should search use google(www.google.com) to look for common things like that first.It will get you an answer in much less time(and I won’t have to type this )

Hey!

Okey I see. I’ll try and get back to the list, there must be a good way to do this, I’ll also check it up with some of my friends!

Thanks!

Joda

Originally posted by zen:
[b]I actually have no idea.That’s why I didn’t mention it in the previous post .But I did do a quick google search on ‘static linking’ and came up with a page with the following:

[quote]
gcc - surround the libraries you wish to link statically with -static and -dynamic (in that order). For example:
% gcc -o foo foo.o bar.o -L/s/X11R6.3-1/lib -R/s/X11R6.3-1/lib
-static -lX11 -lXext -dynamic -lXt -lSM -lsocket -lnsl

If it doesn’t work you can:
1)do man gcc and look for ‘static’ or ‘dynamic’
2)do a more thorough google search yourself
3)hope someone else will post

In general though(no flaming intended) you should search use google(www.google.com) to look for common things like that first.It will get you an answer in much less time(and I won’t have to type this )[/b][/QUOTE]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.