Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
this is not my repost,
I got solution on my question of executing Win32 application from MFC aplication
which is following questions
Compiling WIN32 application using Command Prompt[^]
and
Compiling WIN32 Application from mfc application[^]

using CL command as per CPallini[]

Suggestion.
Thing work fine still single file complilation like Win32 project has on .cpp file compile this .cpp file and get exe.

But problem arises for dependance,
that in main() method of Win32 API if i used function AddTwoNumber() a member function of CTrailABC in TrailABC.cpp and TrailABC.h files

now when i execute The main file using CL command i get .obj file correct but while creating exe file i get linking error like,

unresolved symbol AddTwoNumber()


[EDIT]
My Files also contain .h files so how to link .h file without creating obj file of .h (Because .obj file of .h file is not created)
[/EDIT]
Posted
Updated 17-Sep-11 1:12am
v3
Comments
Richard MacCutchan 17-Sep-11 7:17am    
I already explained to you that you need to add linker options to include any dependent modules. You will also (obviously) need to compile TrailABC.cpp in order to create its object module. Take a look back at the link I posted for more information on compiling and linking.

You need to add the linker options to your CL command; see here[^].
 
Share this answer
 
Comments
Coder Block 17-Sep-11 1:52am    
I want to link from program using batch file
Richard MacCutchan 17-Sep-11 7:15am    
Judging by the latest update to your original question and this message, you seem to be confused about how source code is used to create executables. If you want to compile and link from a batch file then you need to explain what is stopping you; just create a batch file with the requisite cl commands and run it.
As an alternative to Richard (good) suggestion, you may invoke CL passing all the source filenames you need, e.g.
CL main.cpp auxsrc1.cpp auxsrc2.cpp ...
 
Share this answer
 
Comments
Coder Block 17-Sep-11 1:51am    
Its not working
CPallini 17-Sep-11 4:31am    
That's a bit vague. What do you mean exactly? I made a test on my system.
Coder Block 17-Sep-11 1:55am    
what about .h files??
CPallini 17-Sep-11 4:33am    
CL has an option for this (the /I switch). Check out CL documentation, for instance
http://msdn.microsoft.com/en-us/library/19z1t1wy(v=VS.100).aspx
Coder Block 17-Sep-11 4:38am    
Thanks for please see my new post i explain little bit more

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