Solved

VC++ question: building using only OBJ files

Posted on 1998-08-27
8
259 Views
Last Modified: 2012-05-04
Hi,
How can I build an application using only the needed OBJ files (no sources) when the makefiles are generated using VC++?  The problem is that NMAKE looks for the CPP files for depenedencies.  I want to do this with minimal changes to the makefile...
0
Comment
Question by:haima
8 Comments
 

Author Comment

by:haima
ID: 1171417
Adjusted points to 100
0
 
LVL 3

Expert Comment

by:xyu
ID: 1171418
Try something like that :)

link /out:result.exe obj1.obj obj2.obj ... objN.obj

check more options of the link.exe ... it placed at ...\DevStudio\vc\bin... You can run ..\devstudio\vc\bin\vcvars32.bat to set path ans other options to run link and other command-line utils...

You can get help on link.exe by typing "link.exe | more"

Good luck

0
 

Author Comment

by:haima
ID: 1171419
Ah... but that I already knew...
I want to do the build using the original makefiles (with possibly changes that can be obtained from a script...) so that maintainance will be minimal.  In this way I will have to update the Obj list every time, not to mention the libs used and various linker options...
0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1171420
Here's an idea: I don't even know if this is possible...
Alter the make file to check for a cmd line param named "LINKONLY" and have it skip the compilation step if this is set.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 2

Expert Comment

by:kinkajou
ID: 1171421
Don't you just need to create a new rule for the obj's.

You have to edit the makefile in some way. You could do some creative script/batch file programming to utilize environment variables and such. But I can not be more specific without know more about what you are trying to do. You indicate that the number of obj's will change? Use an environment variable, like obj_files_to_link, to indicate the obj's to be linked and have the make file use a line like "$(link_path)\$(linker) $(link_options) $(obj_files_to_link) where link_path is the path to your linker, linker is the link executable, link_options are the options desired.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1171422
You can cheat :

1. Exit VC
2. Set the PC clock back to the beginning of time (or any date back before the OBJs were created).  BTW for DOS the world began in 1980.
3. Create dummy .c or .cpp files.  These should have really old file dates (you can check this from DOS)
4. Set the PC clock back to today's date
5. Restart VC and add the dummy .c files to your project.

The make file generated by VC will assume that compiling the .c files build the .obj's.  However because the .obj's are always newer than the .c files, they will never be compiled, however they will still be linked.

There are some "issues" with this quick'n'dirty approach:
1. "Rebuild all" will force the .c's to be compiled.  Therefore never pick this option
2. Be careful not to ever edit the dummy .c files (or you'll modify the date back forward and thus make the objs be wrongly rebuilt next time you compile)
3. Transfering over a network, e-mail, config management system or whatever that stuffs this up if the file dates are modified.

Within these limitations, this will work, but I wouldn't recommend it.  Personally I prefer a manually built make file for this type of situation, but that's clearly what you don't want.

0
 

Author Comment

by:haima
ID: 1171423
Well I guess this will work (I kinda thought of it myself) but it is a little complicated... I was kind of hoping for a simpler solution (maybe a flag for nmake that can be used smartly to produce this effect and such...)
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1171424
Yeah, well you might have gotten an actual solution from me but instead you hastily accepted a hack. As long as it works for you. Good Luck.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now