Hello everyone,
I am curious if there is a way of linking compiled object files inside the Code Blocks IDE? For example, I have written some low level I/O functions in assembler and have compiled it with NASM assembler. I have the win32 .obj (I am compiling on windows), is there a way to link this within code blocks so when I build the project I can reference these functions in my main() program?
I know I can call ld.exe main.o file1.o file2.0 and link it, but I want code blocks to do that for me?
Any C::B vets around? It would be much appreciated.
(OOPS I posted in wrong thread, I thought this was Off Topic (( ) Sorry!
Code Blocks IDE and Linking ASM
Re: Code Blocks IDE and Linking ASM
(will be moved soon, i guess...)
I'd suggest that you learnt how to write functions in assembler code, that way the compiler would make an OBJ with the binary code, and the proper interface. and would be less complex to link with other programs.
I'd suggest that you learnt how to write functions in assembler code, that way the compiler would make an OBJ with the binary code, and the proper interface. and would be less complex to link with other programs.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 288
- Joined: Wed Oct 29, 2008 12:07 pm
Re: Code Blocks IDE and Linking ASM
Mel,
I am a little confused on what your advice is. Maybe I can clarify. I have my .asm files, I run nasm assembler on them to get .obj files. Now I could make these .obj files into a .lib and then link with C::B which should work but I dont know how to make a .lib!
I have done this before inside code blocks and it worked but I am having trouble with the linker settings inside C::B.
Do you know how to make a .lib with a bunch of .obj files ?
Thanks!
I am a little confused on what your advice is. Maybe I can clarify. I have my .asm files, I run nasm assembler on them to get .obj files. Now I could make these .obj files into a .lib and then link with C::B which should work but I dont know how to make a .lib!
I have done this before inside code blocks and it worked but I am having trouble with the linker settings inside C::B.
Do you know how to make a .lib with a bunch of .obj files ?
Thanks!
Re: Code Blocks IDE and Linking ASM
What i meant was that you did something like in here: http://cboard.cprogramming.com/cplusplu ... mingw.html and compiled your project as you'd normally do. The only way i can think of now is using the "ar" command directly on the Windows console, though i guess you are looking for something more elaborate.
You can link .OBJs directly too into an application the same as if they were libs. though i understand that a library is more convenient. Can't you create a project whose output is a library file and the files are the assembly sources?
You can link .OBJs directly too into an application the same as if they were libs. though i understand that a library is more convenient. Can't you create a project whose output is a library file and the files are the assembly sources?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 288
- Joined: Wed Oct 29, 2008 12:07 pm
Re: Code Blocks IDE and Linking ASM
I switch to VS 2010 C++ and I just add the .obj files in the linker section and it works! I forgot extern "C" though lol. I think my C::B setup at work is not setup right because there was already a GCC compiler on this machine and although I can get a simple hello world to build I can not build the sample. I will try at home to confirm if its the setup for C::B.
Re: Code Blocks IDE and Linking ASM
You should be able to do it with any compiler
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Code Blocks IDE and Linking ASM
You know that C::B also has forums so you can ask the C::B developers directly? :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Code Blocks IDE and Linking ASM
In C::B you can use inline assembler in *.c or *.cpp files but in GNU syntax not Intel.
Or put your whole assembler stuff in seperate *.s and *.S files (you can use Intel syntax in this case too).
Note: *.s *.S are case sensitive under windows too !!!
One of them are preprocessed by the C++ preprocessor the other not.
(I can't remember witch of them are ignored by the C++ preprocessor)
Add *.s or *.S files to your C++ C::B project the rest is done by the IDE and gcc.
DJ.
Or put your whole assembler stuff in seperate *.s and *.S files (you can use Intel syntax in this case too).
Note: *.s *.S are case sensitive under windows too !!!
One of them are preprocessed by the C++ preprocessor the other not.
(I can't remember witch of them are ignored by the C++ preprocessor)
Add *.s or *.S files to your C++ C::B project the rest is done by the IDE and gcc.
DJ.
(Sorry about my bad English)