News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

problem creating static library

Started by jeromecaron, September 24, 2009, 09:24:20 PM

Previous topic - Next topic

jeromecaron

Hello,

I have a collection of .c and .h files that contains several functions.

When I try to create a static library (with project = static library), the file that is generated has the .a extension (as for Linux).
But I have Windows XP. :?
Then I cannot include it in a console application, I think I need a .lib file.
How should I set the code:blocks parameters to create the .lib file ?

I think there is something I am missing about the use of code:blocks.
(If this is only a programming issue, sorry for polluting the forum.)

Thanks for your help

Jerome

oBFusCATed

If you're using mingw, *.a file is OK...

What does it mean, you can't include it?
Look here for hints: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

jeromecaron

Well, I didn' t know it was possible to use the .a file with windows. This already helps.

To use the .a file I do it this way
- I create a console application project
- I include the .a file + all the headers (.h files)
- I also include a main.cpp program that mentions the headers to be able to use the functions
- I tells the linker to look for the .a file (Project --> Build options --> linker settings --> link libraries, in Debug mode)

Then at compilation
Quotemingw32-g++.exe  -o bin\Debug\SigmaClipping2.exe obj\Debug\main.o obj\Debug\libcfitsio.o    "C:\Documents and Settings\Jerome Caron\Desktop\MODELS\CandC++projects\Audine\SigmaClipping2\libcfitsio.a"
mingw32-g++.exe: obj\Debug\libcfitsio.o: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

I don't understand why it is asking for the .o file. All the information should be in the library. So I thought it could be due to the fact that a .lib file is required.

What do you think ?

Jerome

oBFusCATed

Quote from: jeromecaron on September 24, 2009, 10:25:08 PM
- I include the .a file
What does that mean?
You add it to the project like you have added the *.h/*.c files?
If so that is quite wrong.

See "project -> build options -> linker -> link libraries"
and "project -> build options -> search dirs -> linker"

Also look here:
http://vladimir_prus.blogspot.com/2009/06/linking-101.html
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

jeromecaron

You are right,
when I remove the .a file that I included as the .cpp and .h, then it works !  :D
And this makes sense, I understand my mistake.

Many thanks for your help,

(to the moderator = sorry for this post, I realize that it was in fact a basic programming issue)