2006-12-18

Quick Question

Right now I'm building a dll file on Windows using the following make file:

all: sum.dll

sum.o: sum.c
gcc -c sum.c

sum.dll: sum.o
gcc -shared -o sum.dll sum.o


To build a so file on Unix I have to change the first and last lines to read sum.so instead of sum.dll. The same thing applies on OS X, but there I want to build sum.dylib. Does anyone know if there is a little flag or such that I can use to let GCC add the right file extension to the resulting file without having to play around with environment variables and such?

6 Comments:

At 8:53 PM, Anonymous Boyd Stephen Smith Jr. said...

I can tell you definitively: No.

However, most build systems have simple recipes for detecting and using the correct dynamically-linked library extension.

 
At 9:10 PM, Blogger Johan Thelin said...

Thanks for the definitive answer.

I know about detecting and the platform and adapting but I need the file to be clean and simple as possible as I use it in a book text and the focus is not on the Makefile.

 
At 10:37 AM, Anonymous Anonymous said...

Use something different than Make, like SCons (www.scons.org) or CMake (www.cmake.org)

 
At 10:39 AM, Blogger Johan Thelin said...

Thanks for the tip, but that would be to complicate things. I'll just inform the reader that the file name has to be adjusted depending on the platform. It is part of a small example and not the main point of the section that it appears in.

 
At 3:04 PM, Anonymous Tommaso said...

If you look inside the "info" for make you can find a page explaining the conditional (how the if works in Make), in the info at the moment I could not find which variable to test to identify the OS. And I suppose that using autotools would not be a welcome suggestion.

 
At 3:07 PM, Anonymous Tommaso said...

Here the part of the manual talking about Conditionals.

 

Post a Comment

<< Home