We help IT Professionals succeed at work.

Cross compiling

littlec
littlec asked
on
256 Views
Last Modified: 2010-04-15
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
Comment
Watch Question

AxterSenior Software Engineer
CERTIFIED EXPERT

Commented:
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!

Author

Commented:
DOn't you read the Allegro lib part?It is built by linking together gcc and msvc object files. It is a fact.
AxterSenior Software Engineer
CERTIFIED EXPERT

Commented:
>>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.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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.
AxterSenior Software Engineer
CERTIFIED EXPERT

Commented:
>>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

Author

Commented:
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.


Author

Commented:
I prized grg99 for his constructive comment, but points should go to meself because I Alone found solution

Author

Commented:
>>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.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.