Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 1st, 2007, 1:39 AM   #1
kurt
Programmer
 
Join Date: Oct 2005
Posts: 68
Rep Power: 3 kurt is on a distinguished road
Using a VC++ .lib file from g++

Hi.

If I have a .lib file which I think most likely compiled from Visual Studio, can I link that .lib in a project that uses g++/ld ?

I am using mingw32 compiler. I checked the manual -- doesn't seems to indicate any restrictions about this.

Is mingw32 a good choice to begin with?

I know the contents and functions within that .lib. What I am trying to do is building it in a non-visual-studio environment.

Thanks.
kurt is offline   Reply With Quote
Old Nov 1st, 2007, 6:43 AM   #2
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 532
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Using a VC++ .lib file from g++

c++ libraries created with Microsoft compilers probably can not be used with other compilers because of the non-standard way of mangling symbol names, and non-standard format of libraries. I'd suggest you get the source code of the library and compile it with your g++ compiler.
Ancient Dragon is offline   Reply With Quote
Old Nov 2nd, 2007, 8:09 PM   #3
WaltP
Programmer
 
Join Date: Oct 2007
Posts: 39
Rep Power: 0 WaltP is on a distinguished road
Re: Using a VC++ .lib file from g++

Ancient Dragon is right. Trying to use an M$ library with g++ is like trying to use a VW transmission in a Ford truck. They don't play well together.
WaltP is offline   Reply With Quote
Old Nov 2nd, 2007, 9:11 PM   #4
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 754
Rep Power: 3 Jimbo is on a distinguished road
Re: Using a VC++ .lib file from g++

Not directly related, but though I'd mention that this doesn't happen in C, thanks to a lack of name mangling. Unfortunately, if your .lib is already compiled and/or the library code isn't in C, then you'll still have a problem...
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is online now   Reply With Quote
Old Nov 3rd, 2007, 12:06 AM   #5
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,007
Rep Power: 5 lectricpharaoh will become famous soon enough
Re: Using a VC++ .lib file from g++

Quote:
Originally Posted by Jimbo
Not directly related, but though I'd mention that this doesn't happen in C, thanks to a lack of name mangling.
Well, it kind of does. Even in the absence of C++ name-mangling to encode parameter information, the name of a symbol in source was not necessarily the same as its object module counterpart. As an example, some compilers prepend a leading underscore to non-local symbols, whereas others don't. This is aside from all the other differences between object file formats.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick

Last edited by lectricpharaoh; Nov 3rd, 2007 at 12:17 AM.
lectricpharaoh is offline   Reply With Quote
Old Nov 3rd, 2007, 7:22 AM   #6
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 532
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: Using a VC++ .lib file from g++

Quote:
Originally Posted by lectricpharaoh View Post
. As an example, some compilers prepend a leading underscore to non-local symbols, whereas others don't. .
yes I've seen that before two between Microsoft and Borland compilers. Microsoft puts the '_' in front of the symbol name while Borland compilers put it after the name.
Ancient Dragon is offline   Reply With Quote
Old Nov 3rd, 2007, 8:41 AM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Using a VC++ .lib file from g++

Modification of names in C is more commonly called decoration and involves more than underscores. It provides information about the calling convention (who cleans the stack frame, for one).

C++ (and other languages) uses mangling, since it has to provide copious amounts of information (for overloading and other purposes). Each implementation has to convey more information than a simple description of parameters; for instance, interrupts (some due to error conditions) in one chip family may do entirely different things to the stack frame than interrupts from a different chip family. Layout of structs may be constrained by physical memory implementations. All this can make it very difficult to employ a standardized scheme.

Why compilers that deal with the same architecture/hardware use differing schemes is anyone's guess.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 3rd, 2007, 12:41 PM   #8
WaltP
Programmer
 
Join Date: Oct 2007
Posts: 39
Rep Power: 0 WaltP is on a distinguished road
Re: Using a VC++ .lib file from g++

Quote:
Originally Posted by DaWei View Post
Why compilers that deal with the same architecture/hardware use differing schemes is anyone's guess.
That's easy...
Microsoft: "We don't want none o' that Borland sh** being used with our compilers!"
WaltP is offline   Reply With Quote
Old Nov 6th, 2007, 12:30 AM   #9
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,207
Rep Power: 5 grumpy is on a distinguished road
Re: Using a VC++ .lib file from g++

Quote:
Originally Posted by DaWei View Post
Why compilers that deal with the same architecture/hardware use differing schemes is anyone's guess.
That's easy: vendors looking for an edge over competitors. If vendor X can lock a developer into using features that are not supported by (or incompatible with) vendor Y, developers are more likely to stick with vendor X through upgrades, rather than buying a product from vendor Y. Since support of multiple compilers or development environments takes effort, a lot of developers will take the easy path and only use one vendor's compiler.
__________________
Dear God
So far today I've done all right. I haven't been grumpy yet. But in a few minutes, God, I'm going to get out of bed, and from then on I'm going to need a lot more help.
AMEN
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem processing file into a char array csrocker101 C++ 1 May 8th, 2007 11:50 PM
add mutiple users to the smbpasswd file. Pizentios Bash / Shell Scripting 3 Oct 20th, 2005 12:48 PM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 9:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM
Structure char field to a disk file ehab_aziz2001 C++ 0 Feb 10th, 2005 2:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC