C language > Beginner questions

Problem with external library

(1/2) > >>

CBSD:
Hello everybody!

Probably this problem because of me, but...

I tried to link self made (with Pelles C) external library to another Pellec C Windows console project but had no success.  :'( I'd read all recommendations about it on this respectable forum. I'd added my lib to 'Library and object files:'. String looks like this:

kernel32.lib advapi32.lib delayimp.lib dima.lib

Lib dima.lib is mine

I also added my folder to the 'Folders' - Library tab. It looks like this:

I:\Program Files\PellesC\Lib\Win
I:\Program Files\PellesC\Lib
N:\C_work\dima

But it did not help. I got

Building testexe.exe.
POLINK: error: Unresolved external symbol '_dima_fun'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.

again and again. dima_fun is the function that I want to call. This function really is in the dima.lib

Help me please!!!!

TimoVJL:
Perhaps adding a function prototype with right calling convention may help.

like int _cdecl dima_fun(void); etc. depending how you compiled it.

CBSD:
Timovjl your are a man of genius! It works!  ;D But for God's sake, why it dose not work without _cdecl?!  ???

Many thanks!

TimoVJL:

--- Quote ---But for God's sake, why it dose not work without _cdecl?!
--- End quote ---
PellesC support all Windows calling conventions. look at help file.
It works if project and library use same calling convention.
See example project.

PS.
The real genius Pelle explained that to me some time ago.

CBSD:
Thanks again Timovjl!

I see that default calling conv. of EXE project is _cdecl while the LIB project has _stdcall. All we need to do synchronize the calling conventions in LIB and EXE project. For me, it would be more logically to set up the same calling conventions as a default in all types of projects. Though, may be I am wrong.

If this is not very long story, I want to know the purpose of present PellesC logic.

Forward thanks!

Navigation

[0] Message Index

[#] Next page

Go to full version