Click here to Skip to main content
15,741,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a *.lib file that I want to add a *.obj file to. In the past, I used the custom build step feature in MSVC. I build the *.lib then add the additional *.obj file to create an alternate and additional *.lib file.

In the past, I have used the following script in the Custom Build Step command line:
CommandLine="lib /OUT:..\lib\tGenesisi.lib $(IntDir)\ramdll.obj $(TSTUDIO3D)\lib\tgenesis.lib
This would take the tGenesis.lib (build in the current project) and add the ramdll.obj and build a new library file called tGenesisi.lib. BOTH library files would get built.

This technique no longer works with MSVC10. I have been trying all sorts of alternatives for 12 hours straight, including reading everything I can find on the msdn site. If I designate an output file, it is interpreted as an input file and tries to find it... which of course it can't find because I'm trying to BUILD it..If I switch it around, MSVC says that the input file is the same as the output file. I can't get a break.

The rammdll.c file that produces the ramdll.obj is actually PART of the current project but doesn't get linked. It is part of a goofy extern variable scheme in this ancient game engine. It's complicated.

At any rate, I need to get this *obj patched in to my *.lib file. If MSVC won't behave as expected, is there a way I can manually do it with a lib utility, or some other way?


Why is one of those strings using backslashes, and the other (Outputs) using forward slashes?
Share this answer
Why not use nmake?

MS lib utility is called lib.exe
LIB Reference[^]

Visual Studio allows you to create a "Makefile Project" using the "Add New Project" dialog under the "Visual C++" node.

Here is a small nmake tutorial:[^]

NMAKE Reference[^].

Like MSBuild, nmake is a powerfull build tool, but with an entirely different approach and syntax. It's well worth learning, and quite suitable to your task.

Espen Harlinn
Share this answer
Thank you for your replies.

I have tried to run nmake from the command line as suggested... without success.
Here is the script in my make file, tGenesisi_lib.mak...
!include <win32.mak>
$(TSTUDIO3D7)\lib\tGenesisi.lib:$(TSTUDIO3D7)\tGenesis3D\ReleaseDLL\ramdll.obj $(TSTUDIO3D7)\lib\tGenesis.lib
$(LINK) -out:$(TSTUDIO3D7)\lib\tGenesisi.lib $(TSTUDIO3D7)\tGenesis3D\ReleaseDLL\ramdll.obj $(TSTUDIO3D7)\lib\tGenesis.lib

My command line input...
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin>nmake $(TSTUDIO3D7)\tGenesis3D\tGenesisi_lib.mak

the console output...
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.
NMAKE : fatal error U1073: don't know how to make '$(TSTUDIO3D7)\tGenesis3D\tGenesisi_lib.mak'

My confusion persists because according to msdn docs on this error, nmake cannot find the target -- but that is what I am trying to ... make. So obviously I have something very wrong.
Sorry to appeal here. The msdn help used to have useful examples of code and script. I can't seem to find those examples anymore with MSVS10. Help now at msdn is mostly abstract, with very few examples of implementation.
Share this answer
Can you run lib manually, from a command interpreter and does it build the library if all the correct doodads are in place?

Secondly can you transplant this command line into a batch file and run that as a custom build step?

If you can't pull either of those things off then the problem's a bit deeper than MSBuild.


Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900