Link to home
Start Free TrialLog in
Avatar of littlec
littlec

asked on

Cross compiling

The question is about linking with msvc an object file compiled with mingw.First of all, I know that this IS possible,surely.
The question raised when I compiled Allegro library for Windows; it required msvc and gcc. Then I noticed that there were assembly source files that use Unix format(and msvc use Intel syntax, AFAIK). I looked the makefile.vc and I discovered that gcc is used just for compiling assembly files, but ms linker is used for linking together all objects.
I did a try.
I created 2 file one in assembly(with a dummy function), one in c( using assembly function).It works if i build the exe only with mingw.
Then i compiled assembly with mingw and c file with msvc and i link all with ms linker but i have an unresolved reference error.
ok, they are different object file formats it surely possible combining them together. (check Allegro lib).
Thanks for future help
Avatar of Axter
Axter
Flag of United States of America image

Hi littlec,
> First of all, I know that this IS possible,surely.
Not so.
Object files are unique to each compiler, and normally can not be mixed.

David Maisonave (Axter)
Cheers!
Avatar of littlec
littlec

ASKER

DOn't you read the Allegro lib part?It is built by linking together gcc and msvc object files. It is a fact.
>>DOn't you read the Allegro lib part?
The Allegro part doesn't make any sense.  Normal object files are not interchangeable with different compilers.

>>It is built by linking together gcc and msvc object files.

Can you specify EXACTLY what do you mean by object files.


>>(check Allegro lib).
Please provide link or more information so we can check.
ASKER CERTIFIED SOLUTION
Avatar of grg99
grg99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of littlec

ASKER

Object file = intermediate files that end with .o or .obj
I think I've used this term in the correct sense

>>The Allegro part doesn't make any sense.  

OK. Surely my english is bad, but it has a sense. In some way, Allegro library is compiled with either gcc and msvc. Perhaps the different object files are not directly linked together.

>>Normal object files are not interchangeable with different compilers.

YOu CONSIDER YOURSELF A GOD, if you have a so absolute certainty.Did you create all existing compilers??
grg99 is more honest. It give some possibilities.Thanks very much.
>>YOu CONSIDER YOURSELF A GOD, if you have a so absolute certainty.Did you create all existing compilers??

I didn't say it in absolute context.
If I did, I would have said "All object files are not interchangeable with different compilers"

Instead, I said normal object files are not.
I'm sure there are some compilers that can interchange object files, but this is not normal, or typical.

I'm sure you can force an object file to work with other compilers, by modifying the object file, but again, this is not normal usage.

Under normal (typical) usage, object files are not interchangeable with different compilers.


>>OK. Surely my english is bad,
If English is not your primary language, then please look up the word normal, so you can fully understand my commits.
You will note that all compilers come with their own linkers. That is because the .o or .obj files have their own internal formats. There may be objects that are supported by one linker that are not supported (or worse yet, overlaps a different kind of object) by a different linker.

If one person did write all the compilers (as you so facetiously asked), then this problem wouldn't have been so bad. But different people did write the compilers and object files from one compiler may not even be compatible with the linker from a different version of that same compiler.

You need to find the (version specific) format of the object file from each of your compilers, and see if they are compatible. Then you will have the answer to what you are asking.

Bill
Avatar of littlec

ASKER

Axter, I agree with you but the problem is that I was looking for a specific answer but yours is generic.
I know that normal(or typical) object file are not interchangeble, but I refer to specif compilers (msvc and mingw).I told that IN THIS CASE it works, not in all cases.
As I told I know it is possible because I studied Allegro makefile.
Therefore your consideration was useless.

The question was: "How can I do it?".
However now I found the solution: i have to use c language ( not c++) in source file that call assembly function.
 
Sorry for misunderstand.


Avatar of littlec

ASKER

I prized grg99 for his constructive comment, but points should go to meself because I Alone found solution
Avatar of littlec

ASKER

>>I like the way you are thinking but unfortunately that can't be done. :)
Do you speak about assigning points to me?But it was a joke! I didn't want to seem egoistic.However I'm happy you like it.

>>We have to assume that you were perhaps guided towards your answer through the discussion.
Yes, it is so, but in very little part. However I did my choice and I said my reasons.