pc asm book trying to compile first asm app - windows

I can't compile first asm exe
i have MSVC 2005 & 2015
i execute
nasm -f win32 first.asm (ok)
cl first.obj driver.c asm_io.obj (cl not found i set path enviro,
second attempt -> many obj files not found i found it and copy to
source folder,
third attempt ->
asm_io.obj : error LNK2001: unresolved external symbol _scanf
asm_io.obj : error LNK2001: unresolved external symbol _printf
)
using djgpp can't understand what i need to download
downloaded mingw and there is no gcc exe

MSVC does not come with the NASM assembler. You'll need to download that separately, if you do not already have it installed.
MSVC does, however, come with the MASM assembler. You can find steps on how to set it up to work with the IDE here. The problem is, NASM and MASM are not perfectly compatible, syntax-wise. Someone who knows assembly could translate between them trivially, but you will probably have difficulty learning from a book that uses different syntax than your assembler accepts.
Aside from that, I am not sure why you are trying to compile the code after you have assembled it. That is not necessary, and actually won't do anything useful. nasm is an assembler; you run it to assemble assembly code. cl is a C and C++ compiler; you run it to compile c and cpp files. You never need to use cl or gcc when you are writing assembly.

Related

Question for GCC equation.com for building the using static

I like windows gcc equation.com because it like ran natively just like windows compiler. However :
I will need some dll's that not included on distributed package. if i compiled a windows equation.com gfortran program like using Openblas, it will need libgcc_s_seh-1.dll libgfortran-5.dll libquadmath-0.dll libwinpthread-1.dll.
I could find it on web. But how to make it statically linked, i saw libgcc.a libgfortran.a libquadmath.a libpthread.a so i dont have to copy the dll from other. It is possible ?
For several c source code it need include <sys/resource.h> that not included. It's compatible with resource.h from where. After just copied from others, and recompile.
I got error :
c:\gcc\x86_64-w64-mingw32\include\sys\resource.h:74:29: error: unknown type name 'id_t'; did you mean 'pid_t'?
Is there any forum for this type gcc? Is there any debugger for windows gcc that friendly like VisualStudio Community for Intel Fortran.
Regards.

How to link a 3rd party C library using gcc in cygwin

I have a third party C library, both in static format (.lib) and in dynamic format (.dll) with its own import library (.lib). It is MKL (Intel Math Kernel Library). I am working with cygiwn 64 on Windows 7.
In brief, I am trying to get a compiler born to work in POSIX world to talk to a lib compiled in Windows world, assuming that is vene possible.
I want to link that library as part of a C++ executable I am compiling with g++ in cygwin and I am trying to link with the DLL using the import library.
My command line, where I omit the file paths for simplicity, results in a undefined reference error.
$ g++ main.obj mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib -o paper.exe
mkl_intel_lp64_dll.lib: blah, blah, blah: undefined reference to `__GSHandlerCheck'
... and many other similar errors
Anybody knows if it is possible, and, if yes, how to do it?
Thanks
Try rearranging the arguments to g++ so that main.obj precedes the libraries it references.

Compiling assembly code for aarch64

I have generated an assembly file try.s with aarch64 instruction set.I want to compile this on an ARM8 (aarch64 processor) running ubuntu.
my native compiler is gcc(4.8) and i use the following command to compile
gcc -o try.o try.s
I am getting the following errors
Error : ARM register expected -- mov x10,x0
It seems like the aarch4 registers are not being recognized although i thought gcc 4.8 supported aarch64. Can someone tell me what am i missing or is there any special option i should include.Or suggest me a native compiler(not cross-compilers) for doing aarch64.I would also like to use gdb to debug this natively.
gcc is for a 32b targets. 'Xn' registers are not defined for a aarch32 instruction set. That's what compiler tells you.
Right toolchain is aarch64-elf-gcc.
PS: that's a good idea to make asm file extention .S (capital s)

How to resolve the symbol of "printf" instead of "_printf" on win32 console?

test platform is windows 32bit.
So basically I want to assembly + link a snippet of assembly code in these commands:
nasm -fwin32 test.s
cl test.obj /link msvcrt.lib
It says :
error LNK2001: unresolved external symbol printf
In my code I do have function call like this:
call printf
So I changed all of these into
call _printf
and it works.
I am not familiar with programming on windows, but is there any way to resolve the external symbol of printf ?
Because I am doing some automatically transform task, and transformation of all the function calls with _ begin should be very tedious...
Can anyone give me some help..? Thank you!
MSVCRT, like everything compiled with Visual C++, exports cdecl functions using an underscore prefix. For your own libraries, you can override this behaviour, but since MSVCRT is not your library, you can't change that.
You really are going to have to make your assembly calls use the underscore name. But nasm has an option, --prefix, which makes this easier: --prefix _. (Thanks to Frank Kotler for mentioning this.)

Visual studio error compiling Espeak

I'm a Pascal programmer but i need to compile a C library for Windows.
That library is espeak (a voice synthesizer) which uses portaudio lib to access audio port. I have translated the C header into Pascal and have no problem using that library in Linux with the Pascal header.. Also, no problem compiling that lib in Linux (some Make,... and it is done...).
But i want to use it for Windows too...
So i have installed Microsoft Visual Studio and loaded the project.
When I compile the lib, I get messages like:
wavegen.obj : error LNK2019: unresolved external symbol _Pa_Initialize referenced in function "int __cdecl WavegenInitSound(void)" (?WavegenInitSound##YAHXZ)
It seems that the link to the library is not found.
How can i declare what and where that library is (portaudio.dll).
In the code there is #include "portaudio.h" so I think the link to the function is defined.
But I cannot find where it is defined which library (portaudio.dll) to use.
PS : I do not speak great C so some code is very welcome...
Many thanks
You need to make sure that the version of portaudio you are linking to is the same as the version of portaaudio.h that eSpeak compiles to.
The eSpeak sources contain both a v18 and v19 header for portaudio. It also has a portaudio.h which IIRC is a copy of the v18 header.

Resources