User forums > Using Code::Blocks
How do I link files together in codeblock ?
fabien:
Hi everyone,
I have been trying for five days to find the equivalent of
gcc main.c file1.c file2.c -o TEST
both in codeblocks for linux and on windows.
I had before put :
#include "file1.h"
#include "file1.c"
#include "file2.h"
#include "file2.c"
in main.h (with of course #define "main.h" in main.c)
but I do not think it has the effect I am looking for (since I read it is preprocessing intstruction -just a "copy and paste" statement, and not a linking !)
I know it must be a basic question but could someone help me ?
I am no computer scientist but I desesperatly need to make my algorithm work for my project.
I have read somewhere it is enough that the files be in the same project, that codeblock makes the links. It is not true. It doesn't work !
Sincerely,
fabien
stahta01:
TURN ON Full Compiler Logging!
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Then, post what the build log is currently and then below that say what you think is wrong.
Note: The reason for Caps and exclamation point is I have tried to help 5 people know who all failed to turn on "Full Compiler Logging" If you fail I will just give up helping newbies.
Edit 1: Code::Blocks is a two pass system; you will never get exactly what you want. You might wish to use a custom MakeFile; but, since that is hard for a newbie not sure what is best.
--- Code: ---gcc main.c file1.c file2.c -o TEST
--- End code ---
Below is likely to be linking command
--- Code: ---gcc main.o file1.o file2.0 -o TEST
--- End code ---
Tim S.
fabien:
Thank you for your help, Tim.
I turned on the full compiler loggin, but it doesn't say it has problem while compling nor does it say what it links : just the black window of the program running in what seems to be an infinite loop. Still, the file I use (nauty) is a package widely used hence I do not think there is a mistake in it.
I am looking at
http://www.opussoftware.com/tutorial/TutMakefile.htm#Dependency%20Lines:
to learn how to make a makefile.
Could you just tell me if I am wrong that #include "blabla.c", etc, are NOT what I should do to link files together ? In fact the only #include I should have is
#include main.h
in main.c
and
#include librairies in main.h?
stahta01:
This is NOT a site to teach programing.
You did NOT post Build Log.
You are trying to include files that are not headers; this is NOT normally done.
Without info, there is no way to help you.
I do not have desire to read web pages to learn what you are supposed to learn.
Goodbye,
Tim S.
fabien:
Hi,
Could you JUST tell me how one usually LINK files in Codeblocks ?
In most manual about programming they spend plenty of time of talking about loops, variables and other things any idiot can understand but they don't mention linking enough ! The manual of codeblock is a example where they describe a lot of things that are details and to not tell you how you link your file !
It would help me a lot.
fabien
Navigation
[0] Message Index
[#] Next page
Go to full version