Author Topic: [solved] Visual Studio 2008 and NASM integration - PRJ0019 compilation error  (Read 21766 times)

Offline trismarck

  • Jr. Member
  • *
  • Posts: 6
Hi,

I've installed Visual Studio 2008 and attached the NASM compiler to VS2008.
I've created a simple project and I don't know why the project won't compile.
The project is Win32 console application. I have two files inside: asmTest1.cpp and assemblyLang.asm.
Here are the contents of the files:
Code: [Select]
// asmTest1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
extern "C" int foo(void) ;

int main()
{
std::cout << "Lets see if this works." << foo() << "\n" ;
system("pause 1>nul") ;
return 0;
}


Code: [Select]
section .text ; makes this executable
global _foo ; makes visible to linker
_foo:
mov eax,7 ; just return a constant
ret

When I press F5, I get an error:
Code: [Select]
error PRJ0019: A tool returned an error code from "Assembling..."    file:asmTest1
The questions:
1. why the above doesn't work? (it looks like the NASM compiler is working, I've selected the Custom Built Option for the project)
2. How to see a NASM debug message in Visual Studio 2008 (if can't be seen, what tool/IDE should I use to compile my program?)

I've never programmed in assembler before.
« Last Edit: June 04, 2012, 04:45:10 PM by trismarck »

Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: Compilation error - Visual Studio 2008 and NASM
« Reply #1 on: June 04, 2012, 03:31:49 PM »
That is exactly the point. NASM is not working, hence error PRJ0019.  What does your command string to NASM look like?

Offline trismarck

  • Jr. Member
  • *
  • Posts: 6
Re: Compilation error - Visual Studio 2008 and NASM
« Reply #2 on: June 04, 2012, 04:04:14 PM »
Thanks for the reply
When I right click on my project and select: Custom Build Rules, the following window pops up:


Ok, thanks to TightCoderEx I was able to pin down what was wrong.
For some reason, the $(ProgramFiles)\nasm directory entry was missing from Tools: Options: Projects and Solutions: VC++ Directories list. I remember I've added the entry before, so maybe it was deleted by VS2008 for some reason?
Anyway, this is how the correct debug output looks like:
Code: [Select]
'asmTest1.exe': Loaded 'C:\Documents and Settings\ddd\My Documents\Visual Studio 2008\Projects\20120604\asmTest1\Debug\asmTest1.exe', Symbols loaded.
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'asmTest1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.
'asmTest1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcp90d.dll', Symbols loaded.
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll'
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'asmTest1.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
The program '[3100] asmTest1.exe: Native' has exited with code 0 (0x0).

When I make a syntax error it looks like this:


Another question: how did you know that the NASM compiler was not working, if, when an error in the assembly code occurs, the end compiler message (PRJ0019) is the same as in my first post?
« Last Edit: June 04, 2012, 04:17:17 PM by trismarck »

Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: Compilation error - Visual Studio 2008 and NASM
« Reply #3 on: June 04, 2012, 04:22:49 PM »
Unless VS parses custom rule in a manner these have some meaning, but NASM doesn't understand [AllOptions] [AdditionalOptions] or [Inputs].

My experience is with VS6 and I haven't used that since 2005, but what I do remember of doing this type of thing, is that there was a correlation between this rule and the properties set for each individual file.

Offline trismarck

  • Jr. Member
  • *
  • Posts: 6
Re: Compilation error - Visual Studio 2008 and NASM
« Reply #4 on: June 04, 2012, 04:42:34 PM »
At first I've thought that this behavior is strange (by behavior I mean that VS displays the NASM rule under Custom Build Options, even if I haven't provided VS with the path to the NASM folder).
Later on I realized that the $(ProgramFiles)\nasm string I've entered in VS options is the string (a directory) in which VS will search for the _*.exe_ files. In addition to entering the *.exe file location, I've copied the VS .rules file from the nasm folder to VS folders.

Quote
Unless VS parses custom rule in a manner these have some meaning, but NASM doesn't understand [AllOptions] [AdditionalOptions] or [Inputs].
the []'s (and the rule itself) was automatically imported by VS (I haven't entered the rule manually). So the rules is probably ok.