Author Topic: Code won't link using Microsoft Visual C++ 6  (Read 24368 times)

Offline JackDriver

  • Multiple posting newcomer
  • *
  • Posts: 16
Code won't link using Microsoft Visual C++ 6
« on: March 09, 2008, 10:48:06 pm »
Hi,

I am new to code::blocks and am trying to get a simple "Hello World" project to work using Microsoft Visual Studio 6 on Windows XP. I have set the compiler & debugger setting correctly with VS6 as the default compiler, created the project as a console application and am using the supplied "Hello World" code.

The program is compiled correctly but doesn't link and reports "Nothing to be done". To find out why I put "Full command line" debugging ON which indicates that it is going to link but noting happens. Below is the log output

\Microsoft Visual Studio\VC98\Include\SYS" /I"C:\Program Files\Microsoft Visual Studio\VC98\ATL\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include"  /c main.cpp /Foobj\Debug\main.obj
main.cpp

LINK.EXE /nologo /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\Lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib"  /out:bin\Debug\hello2.exe msvcrtd.lib msvcprtd.lib  obj\Debug\main.obj   /DEBUG
Nothing to be done.


If I copy and paste the link command into a command window the linker works and the .exe is produced and runs correctly.

I have also created same project using GNU CC compiler as the default and everything works fine, i.e. code is compiled and linked and runs OK.

Any suggestions as to how to solve this problem would be greatly appreciated as I hop to use CB to produce cross platform (Windows and Ubuntu) code.




Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code won't link using Microsoft Visual C++ 6
« Reply #1 on: March 09, 2008, 11:03:08 pm »
Any suggestions as to how to solve this problem would be greatly appreciated as I hop to use CB to produce cross platform (Windows and Ubuntu) code.

No suggestions, because I don't use M$ Compilers on XP at the moment.

... but if you want to do cross platform developping, it would be much more comfortable to use gcc on both platforms.

Offline JackDriver

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Code won't link using Microsoft Visual C++ 6
« Reply #2 on: March 10, 2008, 12:36:07 am »
Yes, that would be nice. But to convince my work colleagues I want to be able to demonstrate that CB can work with just abount any compiler/linker combination (as it claims!).

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Code won't link using Microsoft Visual C++ 6
« Reply #3 on: March 10, 2008, 01:14:35 pm »
Yes, that would be nice. But to convince my work colleagues I want to be able to demonstrate that CB can work with just abount any compiler/linker combination (as it claims!).

In all fairness,  work colleagues would be using virtually anything but the VC6 compiler as it was released well prior to the standard being released (and has many known quirks).  Have you tried a more recent VC toolkit?  They are available for free from the microsoft website.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Code won't link using Microsoft Visual C++ 6
« Reply #4 on: March 10, 2008, 05:30:30 pm »
\Microsoft Visual Studio\VC98\Include\SYS" /I"C:\Program Files\Microsoft Visual Studio\VC98\ATL\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include"  /c main.cpp /Foobj\Debug\main.obj
This commandline looks like there's no compiler? Should it not read CC.EXE or MSVC.EXE or something as the first thing?

The linker looks good:
Quote
LINK.EXE /nologo /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\Lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib"  /out:bin\Debug\hello2.exe msvcrtd.lib msvcprtd.lib  obj\Debug\main.obj   /DEBUG


I'd recomment looking under toolchain executables, if there is anything sensible set for the compiler at all (doesn't look like).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code won't link using Microsoft Visual C++ 6
« Reply #5 on: March 10, 2008, 05:44:45 pm »
You didn't tell us anything about your setup. VC6 is *not* supported natively with C::B. However, it can be setup so that it is functioning. I hope you have read:
http://wiki.codeblocks.org/index.php?title=Integrating_Microsoft_Visual_C_6_with_Code::Blocks_IDE
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline JackDriver

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Code won't link using Microsoft Visual C++ 6
« Reply #6 on: March 10, 2008, 10:55:24 pm »
Hi,

Yes I have read and followd the instructions in
http://wiki.codeblocks.org/index.php?title=Integrating_Microsoft_Visual_C_6_with_Code::Blocks_IDE

It would appear that I missed a part of the build log  in my original post. Here is the complete output.

-------------- Build: Debug in hello2 ---------------

CL.EXE /nologo /W3 /EHsc  /Zi /D_DEBUG /MDd  /MDd   /I"C:\Program Files\Microsoft Visual Studio\VC98\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\Include\SYS" /I"C:\Program Files\Microsoft Visual Studio\VC98\ATL\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include"  /c main.cpp /Foobj\Debug\main.obj
main.cpp

LINK.EXE /nologo /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\Lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib"  /out:bin\Debug\hello2.exe msvcrtd.lib msvcprtd.lib  obj\Debug\main.obj   /DEBUG
Nothing to be done.


What mystifies me is that CB has logged that it was linking but did not link.

Settings from Compiler & Debugger  are as follows:

Compiler's installation dircetory: C:\Program Files\Microsoft Visual Studio\VC98
C Compiler: CL.EXE
C++ Compiler: CL.EXE
Linker for dynamic libs: LINK.EXE
Linker for static libs: LINK.EXE
Make program: NMAKE.EXE

Additional Paths:
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
C:\Program Files\Microsoft Visual Studio\Common\Tools


Search directories:
C:\Program Files\Microsoft Visual Studio\VC98\Include
C:\Program Files\Microsoft Visual Studio\VC98\Include\SYS
C:\Program Files\Microsoft Visual Studio\VC98\ATL\Include
C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include



As to the question of why I am using VC6 it is because I am dealing with a legacy system currrently running under DOS that we need to move to a Windows environment. I am hoing to be able to convince people to move to a NIX like Ubuntu and having a good cross devlopment IDE like CB would be a good start.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Code won't link using Microsoft Visual C++ 6
« Reply #7 on: March 11, 2008, 01:49:33 am »
I have Microsoft Visual C++ 6 on my PC, do you have a simple project that displays the error. That I can download to duplicate the issue. I do not use Microsoft Visual C++ 6 with Code::Blocks, but can set it up under Code::Blocks.

Note, I suggest trying the release build instead of the debug build. With the express 2005, the release builds work OK, but it is hard to get debug build to work. The express edition seems to be missing some of the debug DLLs so it has link issues. I have no idea if Microsoft Visual C++ 6 could have the same issue.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Code won't link using Microsoft Visual C++ 6
« Reply #8 on: March 11, 2008, 07:20:03 am »
I just compiled a MFC program using Code::Blocks and MSVC6.

My Settings from Compiler & Debugger are as follows:

Compiler's installation dircetory: C:\Program Files\Microsoft Visual Studio\VC98
C Compiler: CL.EXE
C++ Compiler: CL.EXE
Linker for dynamic libs: LINK.EXE
Linker for static libs: LINK.EXE
Make program: NMAKE.EXE

Additional Paths:
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin

Search directories (Compiler and resource Compiler):
C:\Program Files\Microsoft Visual Studio\VC98\ATL\Include
C:\Program Files\Microsoft Visual Studio\VC98\Include
C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include


Search directories (Linker):
C:\Program Files\Microsoft Visual Studio\VC98\Lib
C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib


Did you add Search directories for linker?

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JackDriver

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Code won't link using Microsoft Visual C++ 6
« Reply #9 on: March 11, 2008, 07:31:22 am »
Hi Tim,

Yes I have the following search paths for the linker:

C:\Program Files\Microsoft Visual Studio\VC98\Lib
C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib


I tell you, it got me mystified! Is it possible that CB is not performing the link even though it logs the message below?

LINK.EXE /nologo /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\Lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib"  /out:bin\Debug\hello2.exe msvcrtd.lib msvcprtd.lib  obj\Debug\main.obj   /DEBUG

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Code won't link using Microsoft Visual C++ 6
« Reply #10 on: March 11, 2008, 02:12:29 pm »
Please give me the steps you used to generate the "Hello World" code, it could be a bug in the code.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JackDriver

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Code won't link using Microsoft Visual C++ 6
« Reply #11 on: March 12, 2008, 03:43:39 am »
Hi Tim,

The steps I took were:

1. Downloaded CB and installed on my PC

2. Configured Microsoft Visual C++ V6 as the default compiler, setting options as req'd under Settings->Compiler and debugger including "Full command line" logging.

3. Created a new project using File->New->Project and followed the Wizard steps:
Console Application,
C++, Project title=hello, Folder=c:\tmp,
Complier = Microsoft Visual C++ V6,
Create "Debug" configuration: Ouput Dir = bin\Debug, Objects output dir = obj\Debug
Create "Release" configuration: Ouput Dir = bin\Release, Objects output dir = obj\Release
Multi-threaded Dynamic CRT mode

4. Used the "Build" toolbar button to compile and link

The result was that the code compiled (object files were created) but not linked (no .exe created) and the message "Nothing to be done" in the log window following the linker command.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Code won't link using Microsoft Visual C++ 6
« Reply #12 on: March 12, 2008, 05:11:07 am »
3. Created a new project using File->New->Project and followed the Wizard steps:
Console Application,
C++, Project title=hello, Folder=c:\tmp,
Complier = Microsoft Visual C++ V6,
Create "Debug" configuration: Ouput Dir = bin\Debug, Objects output dir = obj\Debug
Create "Release" configuration: Ouput Dir = bin\Release, Objects output dir = obj\Release
Multi-threaded Dynamic CRT mode

4. Used the "Build" toolbar button to compile and link

The result was that the code compiled (object files were created) but not linked (no .exe created) and the message "Nothing to be done" in the log window following the linker command.


Here's my build log

Code
-------------- Build: Debug in hello ---------------

cl.exe /nologo /W3 /EHsc  /Zi /D_DEBUG /MDd    /I"C:\Program Files\Microsoft Visual Studio\VC98\ATL\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\Include" /I"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include"  /c main.cpp /Foobj\Debug\main.obj
main.cpp
link.exe /nologo /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\Lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\VC98\MFC\Lib"  /out:bin\Debug\hello.exe msvcrtd.lib msvcprtd.lib  obj\Debug\main.obj   /DEBUG
LINK : LNK6004: bin\Debug\hello.exe not found or not built by the last incremental link; performing full link
Output size is 28.08 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

The exe was created in bin\Debug sub-folder and runs under C::B and from CMD window.

Are you running SP6?
Checking NMAKE version seems the best, mine is 6.00.9782.0

Code
C:\Program Files\Microsoft Visual Studio\VC98\Bin>CALL "C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat"
Setting environment for using Microsoft Visual C++ tools.
C:\Program Files\Microsoft Visual Studio\VC98\Bin>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]
C:\Program Files\Microsoft Visual Studio\VC98\Bin>NMAKE.EXE

Microsoft (R) Program Maintenance Utility   Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JackDriver

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Code won't link using Microsoft Visual C++ 6
« Reply #13 on: March 12, 2008, 10:31:50 pm »
Hi Tim,

Yes I am running SP6 for VC6 and have checked the nmake version which is identical to yours. If I run the linker command as logged from a DOS cmd window in the project directory then the link occurs correctly.

I have just deleted the entire projct and regenerated it as before with the same results. Below is the contents of the hello.cbp file:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
   <FileVersion major="1" minor="6" />
   <Project>
      <Option title="hello" />
      <Option pch_mode="2" />
      <Option compiler="microsoft_visual_c_6" />
      <Build>
         <Target title="Debug">
            <Option output="bin\Debug\hello" prefix_auto="1" extension_auto="1" />
            <Option object_output="obj\Debug\" />
            <Option type="1" />
            <Option compiler="microsoft_visual_c_6" />
            <Compiler>
               <Add option="/Zi" />
               <Add option="/D_DEBUG" />
               <Add option="/MDd" />
            </Compiler>
            <Linker>
               <Add option="/DEBUG" />
               <Add library="msvcrtd.lib" />
               <Add library="msvcprtd.lib" />
            </Linker>
         </Target>
         <Target title="Release">
            <Option output="bin\Release\hello" prefix_auto="1" extension_auto="1" />
            <Option object_output="obj\Release\" />
            <Option type="1" />
            <Option compiler="microsoft_visual_c_6" />
            <Compiler>
               <Add option="/Ox" />
               <Add option="/DNDEBUG" />
               <Add option="/MD" />
            </Compiler>
            <Linker>
               <Add library="msvcrt.lib" />
               <Add library="msvcprt.lib" />
            </Linker>
         </Target>
      </Build>
      <Compiler>
         <Add option="/W3" />
         <Add option="/EHsc" />
      </Compiler>
      <Unit filename="main.cpp" />
      <Extensions>
         <code_completion />
         <debugger />
      </Extensions>
   </Project>
</CodeBlocks_project_file>


What I am wanting to know is why "Nothing to be done" is reported. Does CB produce this or is it an output from the linker?

Cheers,
Joseph

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7589
    • My Best Post
Re: Code won't link using Microsoft Visual C++ 6
« Reply #14 on: March 13, 2008, 02:32:41 am »
Basic question, are you doing build or rebuild?
And, is it project or workspace?

Build
Rebuild
build workspace
Rebuild workspace

What happens if you do "run" ?


Tim S
« Last Edit: March 13, 2008, 02:34:30 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org