Reputation: 47
I was finishing a small project that I had in mind(thanks to Tinkernut)to make a small operating system using Assembly. I made it from scratch and when I was done with the main files,I thought of adding some programs into the OS. so,i MADE a edit.asm file(Note:The spaces are part of the code):
; ------------------------------------------------------------------
; RhalexOS Text Editor
; ------------------------------------------------------------------
BITS 16
%INCLUDE 'rhalexdev.inc'
ORG 32768
(Everything else has been removed since it has nothing to do with the problem at hand)
But when I do this(I do have NASM installed): nasm edit.asm -o edit.bin
I get this: edit.bin.7: Unable to open include file 'rhalexdev.inc'
I have been stuck here for an hour.Please help me.
Upvotes: 1
Views: 8073
Reputation: 402
Use -I includepath
.
Include a /
or \
separator at the end of includepath
if you're using old NASM versions.
I am using NASM ver 2.07 and had the same problem. Like I was trying the -i option millions of times and I still got include file not found error. And my include file path was correct, I double checked.
No @David C. Rankin. It's not just like C; it is similar to C.
The problem is that old NASM version did the following when resolving relative include paths:
const char *rel_fpath = parseIncludeDirective();
const char *include_path = nextIncludedPath();
char *full_fpath = newString( strlen(rel_fpath) + strlen(include_path) + 1 );
sprintf(full_path,"%s%s",include_path,rel_fpath);
As you can see at line 4 they simply concatenate the two paths without adding a directory separator. Which means that...
c:\Documents and Settings\Administrator\Desktop\OS Making\programs
and
rhalexdev.inc
becomes
c:\Documents and Settings\Administrator\Desktop\OS Making\programsrhalexdev.inc
With a trailing \
at the end of ...\programs\
, it will just work even in this old NASM version. Newer NASM versions don't need this and will join strings with a directory separator between them.
Upvotes: 1
Reputation: 84521
Oh my goodness. The screenshot does disclose the problem. The problem is you are not compiling in the same directory as rhalexdev.inc
.
You need to either change to the c:\Documents and Settings\Administrator\Desktop\OS Making\programs\
directory before attempting to compile with nasm edit.asm -o edit.bin
or you need to provide an -i
include path when you try to compile in c:\Program Files\nasm
. The problem with the -i
solution is you will have to either quote or escape the include path name to handle the spaces in the directory names.
What I would do is create a directory under your c:\Documents and Settings\your_account\My Documents\nasm
(or whatever name you choose). Then copy all the source files from c:\Documents and Settings\Administrator\Desktop\OS Making\programs\
to c:\Documents and Settings\your_account\My Documents\nasm
. Then in the c:\Documents and Settings\your_account\My Documents\nasm
issue the nasm edit.asm -o edit.bin
command.
I would not recommend compiling in the Program Files
or Administrator\Desktop
directories. You can, just not what I would recommend.
If you want to build in c:\Program Files\nasm
, then you will need to try something like:
nasm edit.asm -o edit.bin -i'c:\Documents and Settings\Administrator\Desktop\OS Making\programs\'
as quoted above with the trailing \
, or with spaces escaped:
nasm edit.asm -o edit.bin -ic:\Documents\ and\ Settings\Administrator\Desktop\OS\ Making\programs\
I suspect this will take care of your problem.
Upvotes: 2