* * *

Author Topic: GetProcedureAddress in linux versus windows  (Read 361 times)

luis

  • Newbie
  • Posts: 2
GetProcedureAddress in linux versus windows
« on: July 25, 2017, 07:07:46 pm »
Hi,
I'm trying to build a program that works both in windows and linux. It uses an open source 3rd party C library that we compile using gcc in linux and Microsoft Visual Studio 2013 in windows (that's the way the developer recommends doing it). I load the library with LoadLibrary and get a non-null value for the handle in both cases. But when I try to load any entry point in windows it seems to want to use a different (decorated?) name. So under linux I would use:
ptr := GetProcedureAddress(handle, 'flInitialise');
but under windows it seems to want for the same function:
ptr := GetProcedureAddress(LibFPGALink, '_flInitialise@12');
If I really need to do that, I can use some ifdefs, but I want to know if that is intended or perhaps I'm doing something wrong.

Thanks

Phil

  • Hero Member
  • *****
  • Posts: 2298
Re: GetProcedureAddress in linux versus windows
« Reply #1 on: July 25, 2017, 07:23:37 pm »
If I really need to do that, I can use some ifdefs, but I want to know if that is intended or perhaps I'm doing something wrong.

Yes, that's correct. If it's a small number of entry points, I would just conditionally compile.

Otherwise, you could compile 64-bits, since function names are not decorated there. Or you could compile 32-bits with clang or gcc on Windows.

https://msdn.microsoft.com/en-us/library/x7kb4e2f.aspx

luis

  • Newbie
  • Posts: 2
Re: GetProcedureAddress in linux versus windows
« Reply #2 on: July 25, 2017, 08:17:08 pm »
Awesome, Thanks. Nothing beats open source support

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus