User forums > Help
Undefined references in projects
Nacho:
Hi! I´m trying to compile an SDL project -created using the CodeBlock´s template for SDL projects- which includes a few source files. After a successful compilation I get linker errors about "undefined references" from my own´s source files. As a simple test I tried the following piece of code, but the error is still there (I get an undefined reference to Vector2DFPDotProd).
#include "MathLibFP.h"
int
main(int argc,char** argv)
{
Vector2DFPType VecA = {1.0f,1.0f}, VecB = {1.0f,1.0f};
Vector2DFPDotProd(&VecA,&VecB);
return 0;
}
I tried cleaning the project and rebuilding, but nothing. Here´s a piece of the project´s makefile:
.deps/MathLibFP.d: MathLibFP.c
@echo Calculating dependencies for "MathLibFP.c"...
@$(default_CC) -MM $(default_CFLAGS) -MF .deps/MathLibFP.d -MT .objs/MathLibFP.o $(default_INCS) MathLibFP.c
.objs/MathLibFP.o: .deps/MathLibFP.d
@echo Compiling "MathLibFP.c"...
@$(default_CC) $(default_CFLAGS) $(default_INCS) -c MathLibFP.c -o .objs/MathLibFP.o
which shows that MathLibFP.c is being compiled. Any suggestions on how to solve this??
Thanks in advance!
--Nacho
Michael:
Hello,
May be this topic could be useful for you.
I would also advice a search in the forum :). There are already some posts about SDL that could be useful for solve your problem.
Michael
Nacho:
Thanks for the link, but my current problem is not related with SDL´s files but with some of my own files (MathLibFP.c/h, for example) that do not contain any SDL code at all. In fact, the SDL program that gets automatically created by CB works ok.
I also searched in the forum but most threads were on "undefined references" obtained by programmers who wanted to compile CB´s source code, which is not my case. Although I did found this thread: http://forums.codeblocks.org/index.php?topic=947.0, that mentions somethings closely related to the problem I´m experiencing:
--- Quote ---- the compiler sometimes gives messages like undefined reference to function f @ some point in some file where that function is not even used :p. Well I know that this is not a very good description, but...
--- End quote ---
Thanks again for your input!
--Nacho
Michael:
Ok, sorry :oops:.
Which version of C::B are you using? And which OS?
Michael
Nacho:
--- Quote from: Michael on January 16, 2006, 09:38:11 pm ---Ok, sorry :oops:.
--- End quote ---
Eh, no problem! Please, don´t feel bad about it. :)
Anyway, I came here to tell you that I finally fixed it, but the steps I took to arrive at the solution are a little bit weird: I removed main.cpp (the one that gets automatically generated by CB SDL´s template), renamed it to blabla.cpp, created and included a new file called main.c, copied the contents from blabla.cpp to main.c and rebuilt the whole project.
I´m using the latets version of CB (the one that includes MinGW) and WinXP. Although I solved my problem, I´d like to know if somebody else has ever experienced a similar problem.
Michael, thanks again for your reply!
--Nacho
Navigation
[0] Message Index
[#] Next page
Go to full version