Jump to content

Create .exe file from object files?

Hawick

I only got .obj files (and .sbr). Is it possible to create executable file from this? As far as I know object-oriented programming works in such a manner that it intially creates .obj files (if the source code does not contain erors) and then it creates .exe from those .obj files.

 

Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

Aren't .obj 3D models? What kind of .exe are you planning to create with this?

Normally if you want to create an .exe from code, you would use your compiler to do that. That doesn't exactly directly work with object files, but rather with classes that have instances (that become objects).

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, minibois said:

Aren't .obj 3D models? What kind of .exe are you planning to create with this?

Normally if you want to create an .exe from code, you would use your compiler to do that. That doesn't exactly directly work with object files, but rather with classes that have instances (that become objects).

I do not have the code anymore just the .obj files. I was wondering if there's a way to load those .obj files from Visual Studio and create executable, since the compiler's job is to create .obj then .exe - I think. I might be wrong.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Hawick said:

I do not have the code anymore just the .obj files. I was wondering if there's a way to load those .obj files from Visual Studio and create executable, since the compiler's job is to create .obj then .exe - I think. I might be wrong.

After Googling it, .obj definitely is (normally) a 3D model format, but can also be used as pieces of code.. alright..

From what I have found, Visual Studio will either have source code (.cs files for example for C# code), DLL files (for classes exported as such). The project usually is a .sln file. 

Do you maybe have the repo somewhere, where you could get the code from again? 

 

From what I Googled around for a bit, it seems like .obj files are indeed (uncompiled) pieces of code, but I couldn't find a way to merge them into a program together.. So sadly can't really provide a helpful comment on that part.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

In order to turn object files into an executable, something called a linker is needed. A linker stitches together the object files, looks at them once more, then resolves all of the references the code makes, these references could be functions or data.

 

If you're compiling code and it only spits out object files, either the compiler script isn't complete or it's missing the linker tool.

Link to comment
Share on other sites

Link to post
Share on other sites

I would just use gcc which would call on the gnu linker ld if this is on Linux. maybe you can do the same on windows with Cygwin or MinGW, idk. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

Well, if your source code is gone, you're gonna have to figure that out with manual tools. Visual Studio will probably not help you much. Read about the build procedures and try to complete them manually. That's gonna be a pain though, might be better to just rewrite the code, depending on what you've got there.

Link to comment
Share on other sites

Link to post
Share on other sites

Object files tend to use the .o-extension. If you want to create an executable from object files, you need to link them together (and make sure that all dependencies exist and are in order), as well as make sure that one object contains a main function. If you dont have a main function, you can link it together into a library instead (.dll or .so), and use it as a dependency for other applications.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×