![]() |
Import Makefile settings to VS2005 IDE
3 Attachment(s)
Hi,
I'm a newbie in this vast world of programming. I've been given some codes in C which are compiled & linked using makefile. I can compile the code using nmake from VS2005. Now i want to build the program in C++ VS2005 IDE. From a quick google search, there seems to be no automated functions in importing makefile settings to VS IDE. I tried to include all the necessary dependecies(header and lib files) stated in the makefile to VS but i get a lot of linking errors. I'm not even sure where to start looking to solve the issue. I hope the gurus can help me out. The makefile including two other related makefile is attached to this post. [1]makefile.mak [2]compiler.mak [3]options.mak In VS I've: [1] Create a new empty project [2] Add exisiting sources (c files and header files) [3] Additional Include Directories: ..../include and ..../src/make7 [4] Additional Library Directories: ..../lib [5] Build project... I got 74 linker errors the VS output after attempted build. Example: Code:
conmain.obj : error LNK2001: unresolved external symbol _MMSd_freeDsMemFunctionCode:
scl_cli.obj : error LNK2019: unresolved external symbol _TAM_parse_address referenced in function _ResolveServerAddressAny advice and comment is greatly appreciated. jjplaw |
Re: Import Makefile settings to VS2005 IDE
> I can compile the code using nmake from VS2005
OK. Start by posting the FULL output from a COMPLETE build from source of the code when built with make. Remove all intermediate files and the executable, use nmake to build the program and redirect the output to a file, then post the resulting file. |
Re: Import Makefile settings to VS2005 IDE
Hi,
I've attached a txt file containing the output of the nmake of the source codes with the nmake options -d -p -g Please advise. jjplaw Code:
Included: ..\..\compiler.mak |
Re: Import Makefile settings to VS2005 IDE
Please try avoiding everything in attachment and I removed the log and moved inline as inline is far easier to read.
|
Re: Import Makefile settings to VS2005 IDE
Noted.
thanks, jjplaw |
Re: Import Makefile settings to VS2005 IDE
What you're looking for here is the link line. This is right at the end of the file from line 332 onwards and the tmp file contains the lines that follow.
This shows what is linked together to make the executable. There are 3 object files, presumably from the source, although I'm not clear why there was only one compile line (line 263) - did you really remove ALL intermediate objects? Anyway, after the three object files there is a list of libraries: 1006_vc.lib, tcli_vc.lib etc, and those are what you need to add to your project in Properties - Linker - Input - Additional Dependencies. |
Re: Import Makefile settings to VS2005 IDE
Hi,
you are right about the compile line.... There should be three... Behold my newbie-ness of extraordinary levels that caused it to only have one compile line: [1] I wasnt too sure what other intermediate files are there besides the obj files, so i started with a fresh copy of the source codes. [2] I have to run a batch file that builds the source codes for microsoft visual c environment. [3] Then i tried to build the particular example using nmake. Output to nmake shows that the exe is updated??? [4] Looking at the log of the batch build process shows that it has already run nmake to build the example. [5] So i just changed a comment/line in one of the c files assuming nmake will recompile everything. [6] I posted that output to the post you see above. [7] After seeing your reply, i did a quick google search only to find out that makefiles only builds the files that have changed. [8] Then i just simply deleted the obj files and the exe, then run nmake again. I got the three compile lines as mentioned by you. I added the stated libraries into Properties-Linker-Input-Additional Dependencies, and i'm able to build the example successfully in VS2005 IDE. I assumed that when i added the folder containing the lib files in Properties-Linker-General-Additional Library Directories, VS will automically use all the lib in that folder if necessary just like when i'm adding Additional Include Directories. But i guess that didnt work because, unlike header files which are declared to be included in the c files itself, the lib files are not mentioned at all..right? So i have to add the names of the particular lib files as additional dependencies, which can be found from either VS default lib folder or additional lib folder. Am i correct with the above assumption? Want to get my basics correct (T_T) Thanks so much for your kind assistance and advice. Really appreciate it (^^,) Sincerely, jjplaw |
Re: Import Makefile settings to VS2005 IDE
> [5] So i just changed a comment/line in one of the c files assuming nmake will recompile everything.
> [6] I posted that output to the post you see above. Yep, that's why I explicitly said "Remove all intermediate files." If you don't, then because of the way make works, this won't have the required effect. Next time a site-recognised expert asks you to do something specific, make sure you do that specific something exactly as specified because there's a good chance that expert knows what he is talking about (I've been programming as a hobby since 1981 and professionally for 20 years, on Windows, various Unix clones, VMS, embedded systems and microcomputers), and if you decide to make an assumption and do something different, that's fine as long as you declare that fact. Anyway in this case it wasn't a problem because it was mainly the link line I was after. > makefiles only builds the files that have changed Yes, that's why we use make files instead of simple batch files. If the dependencies are correctly setup in the makefile then any change to any file will be correctly incorporated into the relevant files to minimise the build time. This can be quite difficult to do with headers dependent on other headers. > VS will automically use all the lib in that folder if necessary No, you have to tell it what libraries to link into the executable. The point of the Additional Directories is to tell it where to find the libraries you specified. This is the same as the make file. > just like when i'm adding Additional Include Directories hmm, so your code doesn't have #include lines that specify which header files to include? Of course it does, and headers and libraries are identical in this respect - you specify what to include and where to find those files, and you can do that in one go with #include "/usr/include/foobar.h" or in two goes with #include "foobar.h" and -I/usr/include. Similarly with libraries you can specify on the link line /usr/lib/foobar.lib or you can specify it in parts with foobar.lib -L/usr/lib. The -I and -L settings are useful if you're including multiple files from the same directory. |
Re: Import Makefile settings to VS2005 IDE
Quote:
Quote:
xpi0t0s, thank you for taking time to help me on my issue and to teach me. am grateful. |
| All times are GMT +5.5. The time now is 09:11. |