简体   繁体   中英

is it possible to link an exe file as a lib file to another project?

The question is in the title.

I have coded an .exe project, I would like to use one of the function of this project in another project.

Maybe it is a silly question, but if it is possible this would limit the number of projects in my solution...

I have given a simple try, I get an LNK1107 error.

I would say it is not possible, but it is hard to find a clear answer on the net.

No, it is not possible.

An executable is a standalone entity. It is the result of linking object files together to produce a self-contained, well, executable.

Linking two executables together will, at best, result in duplicate definitions of main (in reality it's a little more complicated, but…).

What you want to do is share the object files before they become an executable, and this is typically accomplished by moving your shared/common code into a "library" then link the library into both projects.

Alternatively, you could keep the executables all separate, but share the code at the version-control level, eg with SVN externals.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM