Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VC++ question: building using only OBJ files

Posted on 1998-08-27
8
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

722 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