Home

Maxime Viargues

Introduction

VCC4N (Visual C++ Compiler For NetBeans) is a plugin used to compile C/C++ code in NetBeans IDE with Microsoft Visual C++ compiler.

It provides a toolchain and an intermediate program called "msvc_caller.exe" used to call external compiler and linker.

The actual release is a beta version, but allows you to compile full projects (application, static library, DLL) in 32/64 bits.

This version is compatible with NetBeans 8.0 and 7.3+.

No debugger is supported yet.

If you have any questions or feedbacks please post on the forum.

[Release Notes]

Installation

Prerequisite

You must have Microsoft Visual C++ installed. This plugin works with Visual C++ 2010 and higher (including Express), and should work with older versions.

You also need MinGW and MSYS make.exe because projects are still built with Make files.

For more information about how to install them, visit http://netbeans.org/community/releases/72/cpp-setup-instructions.html

Module installation

To install VCC4N, download the latest release, then extract it in the folder of your choice. This folder will be used with NetBeans, so it must stay in place in the future. Do not rename the "tools" folder. Make sure files have read/write permissions.

If you have a previous version of VCC4N installed, it is safer to uninstall the plugin from NetBeans and reinstall it. Also, remove the old "tools" folder and use the new one.

In NetBeans, install the plugin as follow:
- Tools > Plugin
- Downloaded tab
- Press "Add Plugin..." and select "VCC4N.nbm" from the extracted folder
- Then press "Install"
- You must restart the IDE

When restarted, create the toolchain:
- Tools > Options > C/C++ (Build tools tab)
- Press "Add..."
- In "Base directory" select the "tools" folder you have extracted before
- (VCC4N must appear in the fields below)
- Press OK
- Then, as asked, select your Microsoft Visual C++ Folder (or keep the existing one).

If everything goes right you will see "msvc_caller.exe" in C and C++ compilers.
This file will work as an intermediate between NetBeans and Visual C++ compiler/linker.

To build static libraries you will need to use msvc_caller instead of ar.exe:
- In Project Properties > Archiver
- Uncheck "Run Ranlib"
- In Tool, replace "ar" with "msvc_caller"

That's all, now you can use VCC4N as a compiler in your project.

Project configuration

Project properties

The following notes are available in your project's properties.

  • In Build section make sure the tool collection is VCC4N.
  • All the Configuration types are supported (application, static library, DLL).
  • You can use both 32 and 64 bits architecture
  • IMPORTANT: If you want to add options to the compiler/linker using the Additional options field, do not start them with a '/' as usual, but use a '-' instead. This is because the make.exe will recognize any arguments starting with a slash as a path and will convert it to something like "C:/MinGW/bin/option". The '-' will be converted and treated as an argument by msvc_caller.

    For example, instead of writing "/RTC1", write "-RTC1".

You may know that Visual C++ add several options by default to the compiler, which are not in NetBeans, like preprocessor values. Here are some example, but check the options you need to compile your project:

  • Windows or Console application: -D"_WINDOWS" or -D"_CONSOLE"
  • To build a DLL: -D"_USRDLL" -D"MY13_EXPORTS" -D"_WINDLL"
  • Manifest: /ALLOWISOLATION /MANIFEST /ManifestFile:"Release/YourFile.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'"

MSVC Caller

Msvc Caller contains some options in the "msvc_caller.conf" file.

  • vcbin is the Visual Studio path used to call compiler and linker. You can change them here, but it is filled by the plugin when you select the folder.
  • addCompileArgs are arguments added to the compiler each time is called. These are default options used in Visual Studio, but you can change it or add more if you like.
  • addLinkerArgs are the same for the linker
  • verbose is used to display information about compiler/linker calls. You can turn it on if you have unknown compilation errors or if you want to know the full command line used.

The "msvc_env.conf" is automatically generated and contains the environment variables needed to run the compiler/linker. They are generated using the batch named "vcvarsall.bat" in Visual Studio.

Why an intermediate exe?

An intermediate executable called msvc_caller.exe is used by the module instead of the Visual C++ compiler. This choice has been made to bypass some issues due to NetBeans toolchain structure or the usage of make. This is of course not the best solution, but probably the easiest and fastest to get something working.

The first problem is that NetBeans does not allow to use different programs to compile and link. Unfortunately unlike gcc, Visual C++ use two programs cl.exe and link.exe (you can do all with cl.exe, but not separately like in make builds).

Another problem is the usage of make via MinGW which converts all the commands from POSIX to Windows style. Unfortunately all the compiler options in Visual C++ start with a slash and can contain path (like object output /Fo). The make will convert the paths using a POSIX conversion which does not work well all the time (especially when using path in options like /Fo"D:/programs/folder with space").

These are the main reasons of using an intermediate program, but there are some others which make this way easier, because we can control all the inputs and eventually convert them to fit the compiler requirements. Another solution would be not to use the NetBeans toolchain and write a complete separate plugin, but this is a huge job.


Related

Wiki: Release Notes

  • Paul A Bristow
    Paul A Bristow
    2012-11-02

    Thanks. Works for me using NetBeans 7.2. Make C:\msys\1.0\bin\make.exe (gnu 3.81)

    Main snag is that options and link files (eg Boost.Test unit_test_framework are different for different toolchain and so full transfer without manually changing these is not possible. This appears to be a NetBeans restriction, not VCC4N.

    Also debug is set to C:\cygwin\bin\gdb.exe which isn't right (and doesn't work of course).

     
  • Paul A Bristow
    Paul A Bristow
    2013-06-24

    I've tried to install your 0.3.1 but got into a ravel including access rights (now expanded so all
    files and folders have permissions) ending with "Retrieving tool versions" stuck at 50%.

    I am clear that I am unclear how I should be doing an upgrade - or should I remove the previous
    0.2 version (and 0.3.0) before trying to do any of this process?

    I've got the downloaded files at Program Files/Netbeans - does it need to be somewhere in my user
    folder instead? (It worked before).

    Thanks

    Paul

    PS I am uncertain what the Microsoft Visual C++ Folder should be

    It is

    C:\Program Files\Microsoft Visual Studio 10.0\VC

    the C++ compiler is

    C:\Program Files\NetBeans 7.2\VCC4N_0.3.1_beta\tools\msvc_caller.exe

    If I click on the Build Tools/ versions it hangs.

     
    Last edit: Maxime Viargues 2013-06-29
  • Paul A Bristow
    Paul A Bristow
    2013-06-28

    I've started again and RTFM more carefully.

    It seems to find the right microsoft/visual studio/vc/bin folder, and I replied no to the "do you want to change it?" question, but it hangs "Initing tool collection", and if I close, it says

    "Existing the IDE will terminate the following process:
    Retrieving tool versions."

    MY Visual Studio is working but none of the NetBeans tools are :-(

    Time to upgrade to NetBeans 7.3 I think...

     
    • Yes, installing the latest NetBeans 7.3 should fix it.
      Not sure what's wrong. Updating the plugins may have scewed up your NetBeans tools.

       
  • Paul A Bristow
    Paul A Bristow
    2014-02-14

    I have used VCC4N 0.3.1 OK on Netbeans 7.2 on 32-bit Windows 7 Visual Studio 10. But sadly I have failed to install the latest version 0.3.2 on Netbeans 7.4 on 64 windows 8.1 and Visual Studio 12 :-( (Nor has is worked on 32-bit Windows 8 with 3.1)

    When I get to the final step Press OK to select the /tools folder, I do not get an option to provide the MS VC++ folder at all. So No compilers are available

    I've tried to bodge this into action by adding

    vcbin=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin to msvc_caller.conf

    and running the getEnvVars.bat to generate the compiler info in msvc_env.conf
    which fills it plausibly, and the NetBeans tools versions looks plausible too:

    C and C++ compliler msvc_caller 0.030/cl.exe 18.00.21005.1 GNU Make 3.81

    but none of #includes to std library like iostream are found :-(

    And attempts to use it to run a hello world ended thus:

    "/c/Users/Paul/Documents/NetBeansProjects/Hello World/"c:/msys/bin/make.exe"" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
    /bin/sh: /c/Users/Paul/Documents/NetBeansProjects/Hello World/c:/msys/bin/make.exe: No such file or directory
    make.exe": *** [.clean-impl] Error 127

    I would expect just

    "c:/msys/bin/make.exe"-f ...

    Please can you suggest what I am doing wrong?

    Paul

     
    • Hi Paul,

      Thanks for reporting that. It's a compatibility issue with 7.4+, I fixed it but haven't push the new version yet, I'll do it this week end.

      Regards.

       
  • Paul A Bristow
    Paul A Bristow
    2014-02-19

    I have done a fresh install of NetBeans 8.0 beta and deleted all old copies of VCC4n_0.3.* and downloaded 0.3.3 but I still cannot get the call to the MS compiler to work. It is listed correctly on the C/C++ 'Versions' (The code sample works fine with GCC compiler).

    The failure output is

    "/d/Documents/NetBeansProjects/Welcome_1/"C:/msys/bin/make.exe"" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
    /bin/sh: /d/Documents/NetBeansProjects/Welcome_1/C:/msys/bin/make.exe: No such file or directory
    make.exe": *** [.build-impl] Error 127

    The build appears to be calling make.exe wrongly? Make.exe is at C:/msys/bin/make.exe

    Full data attached as text file.

    What am I still doing wrong?

     
    Attachments
    • Ok, that's a bug in NetBeans.
      In Tools > Options > C/C++ > Make Command
      remove the path "C:\msys\bin\" and just leave "make.exe"

       
      • Paul A Bristow
        Paul A Bristow
        2014-02-20

        From: Maxime Viargues [mailto:pitchonel@users.sf.net]
        Sent: Thursday, February 20, 2014 8:15 AM
        To: [vcc4n:wiki]
        Subject: [vcc4n:wiki] Re: Discussion for Home page

        Ok, that's a bug in NetBeans.
        In Tools > Options > C/C++ > Make Command
        remove the path "C:\msys\bin\" and just leave "make.exe"
        "make.exe" is not allowed - shows and red and fails to run at all.
        (even though I have "C:\msys\bin\" in my PATH.
        Posted a request for more help on Netbeans Forum bug 228730
        https://netbeans.org/bugzilla/show_bug.cgi?id=228730 comment 29
        Thanks
        Paul


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/vcc4n/wiki/Home/
        To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

         
        Attachments
  • Paul A Bristow
    Paul A Bristow
    2014-02-20

    Update I have used http://forums.netbeans.org/topic54884.html to effectively change the version of make.exe from 3.82 to 3.99.90 (from mingw). This allows make to run, but now I get

    "c:/msys/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/Users/Paul/Documents/NetBeansProjects/hello2'
    "c:/msys/bin/make" -f nbproject/Makefile-Release.mk dist/Release/VCC4N-Windows/hello2.exe
    make[2]: Entering directory 'C:/Users/Paul/Documents/NetBeansProjects/hello2'
    mkdir -p build/Release/VCC4N-Windows
    msvc_caller -c -Zi -O2 -Oi -W3 -Fobuild/Release/VCC4N-Windows/hello2.o hello2.cpp
    Error: Cannot open file msvc_caller.conf, it may not exist

    But
    getEnvVars.bat, mscv_caller.conf and mscv_caller.exe, and msvc_env.conf do exist with RW in

    C:\Users\Paul\AppData\Roaming\NetBeans\VCC4N_0.3.3_beta\tools

    Netbeans Versions shows

    C++ compiler msvc_caller 0.3.0 cl.exe 18.00.21005.1
    GNU Make 3.99.90
    GNU gdb 7.6

    msvc_caller 0.3.0 looks ??

    Does this help?

     
    • That's weird, the error "Cannot open file msvc_caller.conf, it may not exist" should display the path of the "msvc_caller.conf" file, so it means msvc_caller is called from its own folder, instead of the absolute path.
      Also when you retrieve the compiler version, you should get the same error, but you don't, so this is executed from right path.
      By the way, msvc_caller has a different versioning than the module, so 0.3.0 is correct.

      The tools path "C:\Users\Paul\AppData\Roaming\NetBeans\VCC4N_0.3.3_beta\" could be a problem, try to put it in a different folder than Netbeans, like C:\VCC4N_0.3.3_beta\tools see if it's better.

       
  • Paul A Bristow
    Paul A Bristow
    2014-02-24

    I've used C:\VCC4N_0.3.3_beta\tools with the same result :-(

    msvc_caller -c -Zi -O2 -Oi -W3 -Fobuild/Release/VCC4N-Windows/hello2.o hello2.cpp
    Error: Cannot open file msvc_caller.conf, it may not exist

    Some extracts on config details attached.

    C:\VCC4N_0.3.3_beta\tools contains

    getEnvVars.bat
    mcvc_caller.exe
    ^^^ both unchanged.

    msvc_caller.conf
    msvc_env.conf
    ^^^^ changed by running getEnvVars.bat

    Any other ideas?

    Thanks.

     
    Attachments
  • Paul A Bristow
    Paul A Bristow
    2014-02-25

    I've tried this on my windows 8, win32 machine NB 8 beta without success, but I conclude that it is the version of make.exe that is the likely cause of trouble. See the attached notes. Can you confirm which version you are using (and its source)?

     
  • Paul A Bristow
    Paul A Bristow
    2014-02-25

    On a machine that VCC4N does work (win 7 32) VCC4n 0.3.1 NetBeans 7.2

    C:\msys\1.0\bin>make.exe --version
    GNU Make 3.81
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.

    This program built for i686-pc-msys

    C:\msys\1.0\bin> <<<< note the different directory?

    Does this give any more clues?

     
    • Hi Paul, sorry to see you are still having trouble.

      My Make is 3.81 on Win8 64, but make 32bit. Netbeans 8, Java SDK 1.7.025

      I don't think this problem is particular to VCC4N, but more the way it's called by NetBeans, make or MinGW.
      The different MinGW versions could be a problem indeed. I have downloaded the latest from SourceForge, and I still get make 3.81, not sure where you got yours from.
      https://sourceforge.net/projects/mingw/
      The path should be C:\msys\1.0\bin\make

      It's still working with NetBeans 8 RC.

       
  • Paul A Bristow
    Paul A Bristow
    2014-03-10

    I've tried several (all even ;-) versions of make now. I agree that the version is probably not the final cause (though some versions definitely seem not to work).

    One thing that I have noted is different from the VCC4n working machine and the 2 not-working machines is that the working has cygwin installed. This probably means that there are more than one copy of make.exe somewhere. I don't want cygwin unless necessary, but can you tell me if you have cygwin installed on (all) your working systems?

    Thanks. Paul

     
    • No I don't have Cygwin installed