PDA

View Full Version : C++: how to use *.lib OR *.dll



balagosa
February 2nd, 2009, 03:59 PM
I have this library file called "inpout32.lib", it is a driver created by one of my professors for inter-action with the parallel port for interfacing. The file also comes in "inpout32.dll"

I have this function:
void _stdcall Out32(short data);
which is in the lib OR dll file which i want to import.

The problem:
I want to write a program using gedit. But I do not know how to use the dll OR lib file. If I had an API/software like Visual Studio, it could have been so easy to include in my project/workspace.

nvteighen
February 2nd, 2009, 04:50 PM
Probably, you won't be able to use it as that file is very surely not in a GNU/Linux-compatible format.

What you do is include the header (*.h) and use the functions. Then, in gcc you tell the linker to link your program to that specific library... but again, it has to be in a GNU/Linux-compatible format.

A solution is to ask your professor for the source and recompile that library... (or search for a GNU/Linux-specific library). But, if it's a driver, it may have system-specific (I guess Windows-specific...) stuff that may not be portable.

jespdj
February 2nd, 2009, 09:09 PM
*.lib is a statically linked Windows library; *.dll is a dynamically linked Windows library.

Windows programs and libraries do not work on Linux - it's not going to be possible to use those libraries on Linux directly. If you really have to use those libraries, you have no choice but to program on Windows.

On Linux, dynamically linked libraries have the extension *.so (for "shared object").

Ferrat
February 2nd, 2009, 09:25 PM
*.lib is a statically linked Windows library; *.dll is a dynamically linked Windows library.

Windows programs and libraries do not work on Linux - it's not going to be possible to use those libraries on Linux directly. If you really have to use those libraries, you have no choice but to program on Windows.

On Linux, dynamically linked libraries have the extension *.so (for "shared object").

Well yes and no, he will only be able to compile it for Windows using that lib, "development" is still possible in Linux, you could try it in wine, or just run a virtual machine to test it.

The idea of asking for the source is the best way to go imo, this way you might be able to make a Linux version, perhaps with the help of the professor introducing him to Linux and getting some creds for the extra work??

balagosa
February 3rd, 2009, 11:46 AM
problem is, he is not teaching in the university anymore. So I guess i will have to code in windows then.

BUT I HAVE A BIG QUESTION!

Have you guys ever tried interfacing in Ubuntu, specifically parallel port and USB port. Maybe I can say, making printer software. With your help, I can make my own counter part code for the useless library and dll.

Ferrat
February 3rd, 2009, 12:25 PM
problem is, he is not teaching in the university anymore. So I guess i will have to code in windows then.

BUT I HAVE A BIG QUESTION!

Have you guys ever tried interfacing in Ubuntu, specifically parallel port and USB port. Maybe I can say, making printer software. With your help, I can make my own counter part code for the useless library and dll.

Well just of the top of my head I know Ubuntu and Linux are mostly open source and I do know that Ubuntu can handle printers so I would guess you could just take a look inside their code for USB or parallel port and see what you need to use :p

balagosa
February 3rd, 2009, 12:59 PM
Well just of the top of my head I know Ubuntu and Linux are mostly open source and I do know that Ubuntu can handle printers so I would guess you could just take a look inside their code for USB or parallel port and see what you need to use :p

nice Idea! why did not I think about this. So I guess the right place to look will be at cups-development then.

Anyone can give me a head-start?

nvteighen
February 3rd, 2009, 04:45 PM
nice Idea! why did not I think about this. So I guess the right place to look will be at cups-development then.

Anyone can give me a head-start?
If you just want something that prints, CUPS is the way. But if you want to control some other device through USB or the parallel port, then CUPS won't help you.

clustermonkey
February 6th, 2009, 06:52 AM
If you are just wanting to toggle the data pins of the
parallel port, try the "parapin" project on Sourceforge.
It is a library that provides functions for the printer
port.