PDA

View Full Version : How to link statically lib files made different for INTEL and AMD platforms



AttilaPethe
4th January 2012, 10:55
I am in a strange situations: I linked some library dynamically but I got a lot of memory leakage. To investigate the problem, now I want to link the library statically at "compile time" but I have two different library for INTEL and AMD platforms. These libs does the same things (in fact they are drivers), communicate with the same external device by USB (FTDI made FT4232, but this does not matter now). How to manage this AMD or INTEL platform situation? How can I make a difference between them at runtime? I am confused. Are some docs available about these platform-linking situations?
Thanks for the answers! Attila

Boron
4th January 2012, 11:20
Do the AMD and Intel driver library have the same API (same function names, #defines, etc.)?
If yes you cannot link both statically into your application (at least not without doing some weird things).

If no you need to determine the OEM of the CPU at runtime and make the corresponding library calls. Doing this is platform specific (Win, Linux, etc.). I don't know how to do it in Windows but in Linux there should be /dev/cpu if I remember correctly.

If the AMD and Intel library have different APIs I would suggest to provide a common Interface for them.
The Adapter pattern (according to the "Gang of Four") would be my way to achieve this.

AttilaPethe
4th January 2012, 11:43
All functions have the same name, the same calling parameters, same return types, ..., same "c" type funtion. This was the reason why I linked them dynamically with QLibrary and I think that the static linking is almost a useless thing if we talk about freqvently updated things like drivers. But to detect my memory problem I had no other idea than to try a static linking too... Do you know a good valgrind like tool for windows? Very thanks for the answer!