Welcome! Log In Create A New Profile

Advanced

CFile

Posted by Kajos 
CFile
April 18, 2010 04:37PM
Hello,
I am getting undefined references to a CFile-object. The code I'm trying to compile is meant for linux/windows so there are some hickups in that. Anyways, anyone know what I'm doing wrong / where or how I can correct it?

linking ... stratagus-2.2.4.elf
ai.o: In function `SaveAi(CFile*)':
c:/devkitPro/projects/stratagus-2.2.4/source/ai.cpp:505: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/ai.cpp:506: undefined reference to `CFile::printf(char*, ...)'
ai.o: In function `SaveAiPlayer':
c:/devkitPro/projects/stratagus-2.2.4/source/ai.cpp:339: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/ai.cpp:340: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/ai.cpp:342: undefined reference to `CFile::printf(char*, ...)'
ai.o:c:/devkitPro/projects/stratagus-2.2.4/source/ai.cpp:343: more undefined references to `CFile::printf(char*, ...)' follow
commands.o: In function `EndReplayLog()':
c:/devkitPro/projects/stratagus-2.2.4/source/commands.cpp:755: undefined reference to `CFile::close()'
commands.o: In function `AppendLog':
c:/devkitPro/projects/stratagus-2.2.4/source/commands.cpp:398: undefined reference to `CFile::flush()'
commands.o: In function `CommandLog(char const*, CUnit const*, int, int, int, CUnit const*, char const*, int)':
c:/devkitPro/projects/stratagus-2.2.4/source/commands.cpp:449: undefined reference to `CFile::open(char const*, long)'
editloop.o: In function `CEditor::Init()':
c:/devkitPro/projects/stratagus-2.2.4/source/editloop.cpp:1953: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/editloop.cpp:1954: undefined reference to `CFile::close()'
game.o: In function `LoadStratagusMap':
c:/devkitPro/projects/stratagus-2.2.4/source/game.cpp:112: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/game.cpp:139: undefined reference to `CFile::close()'
c:/devkitPro/projects/stratagus-2.2.4/source/game.cpp:124: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/game.cpp:129: undefined reference to `CFile::open(char const*, long)'
groups.o: In function `SaveGroups(CFile*)':
c:/devkitPro/projects/stratagus-2.2.4/source/groups.cpp:88: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/groups.cpp:89: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/groups.cpp:92: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/groups.cpp:94: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/groups.cpp:96: undefined reference to `CFile::printf(char*, ...)'
interface.o: In function `Screenshot':
c:/devkitPro/projects/stratagus-2.2.4/source/interface.cpp:872: undefined reference to `CFile::close()'
c:/devkitPro/projects/stratagus-2.2.4/source/interface.cpp:869: undefined reference to `CFile::open(char const*, long)'
iolib.o: In function `FindFileWithExtension':
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:467: undefined reference to `access'
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:467: undefined reference to `access'
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:467: undefined reference to `access'
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:467: undefined reference to `access'
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:467: undefined reference to `access'
iolib.o:c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:467: more undefined references to `access' follow
iolib.o: In function `~CFile':
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:75: undefined reference to `CFile::close()'
map_save.o: In function `CMap::Save(CFile*) const':
c:/devkitPro/projects/stratagus-2.2.4/source/map_save.cpp:67: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/map_save.cpp:68: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/map_save.cpp:70: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/map_save.cpp:72: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/map_save.cpp:75: undefined reference to `CFile::printf(char*, ...)'
map_save.o:c:/devkitPro/projects/stratagus-2.2.4/source/map_save.cpp:76: more undefined references to `CFile::printf(char*, ...)' follow
png.o: In function `LoadGraphicPNG(CGraphic*)':
c:/devkitPro/projects/stratagus-2.2.4/source/png.cpp:120: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/png.cpp:307: undefined reference to `CFile::close()'
png.o: In function `CL_png_read_data':
c:/devkitPro/projects/stratagus-2.2.4/source/png.cpp:69: undefined reference to `CFile::read(void*, unsigned int)'
savegame.o: In function `SaveGame(std::string const&)':
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:270: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:284: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:285: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:286: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:287: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:288: undefined reference to `CFile::printf(char*, ...)'
savegame.o:c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:289: more undefined references to `CFile::printf(char*, ...)' follow
savegame.o: In function `SaveGame(std::string const&)':
c:/devkitPro/projects/stratagus-2.2.4/source/savegame.cpp:322: undefined reference to `CFile::close()'
script.o: In function `SaveCcl(CFile*)':
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2577: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2581: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2583: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2585: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2586: undefined reference to `CFile::printf(char*, ...)'
script.o:c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2587: more undefined references to `CFile::printf(char*, ...)' follow
script.o: In function `LuaLoadBuffer':
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:231: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:245: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:262: undefined reference to `CFile::close()'
script.o: In function `LoadCcl()':
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2557: undefined reference to `access'
selection.o: In function `SaveSelections(CFile*)':
c:/devkitPro/projects/stratagus-2.2.4/source/selection.cpp:1135: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/selection.cpp:1136: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/selection.cpp:1138: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/selection.cpp:1139: undefined reference to `CFile::printf(char*, ...)'
c:/devkitPro/projects/stratagus-2.2.4/source/selection.cpp:1141: undefined reference to `CFile::printf(char*, ...)'
selection.o:c:/devkitPro/projects/stratagus-2.2.4/source/selection.cpp:1143: more undefined references to `CFile::printf(char*, ...)' follow
wav.o: In function `CSampleWavStream::Read(void*, int)':
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:127: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:100: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:111: undefined reference to `CFile::seek(long, int)'
wav.o: In function `LoadWav(char const*, int)':
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:197: undefined reference to `CFile::open(char const*, long)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:202: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:215: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:224: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:251: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:324: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:334: undefined reference to `CFile::seek(long, int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:354: undefined reference to `CFile::read(void*, unsigned int)'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:281: undefined reference to `CFile::close()'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:245: undefined reference to `CFile::close()'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:370: undefined reference to `CFile::close()'
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:275: undefined reference to `CFile::close()'
wav.o: In function `~CSampleWavStream':
c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:153: undefined reference to `CFile::close()'
wav.o:c:/devkitPro/projects/stratagus-2.2.4/source/wav.cpp:153: more undefined references to `CFile::close()' follow
collect2: ld returned 1 exit status
make[1]: *** [/c/devkitPro/projects/stratagus-2.2.4/stratagus-2.2.4.elf] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:12
Re: CFile
April 18, 2010 05:57PM
CFile is a Windows MFC class isn't it? I would guess that replacing all instances of "CFile::" with "f" will probably sort most of it out. I may be getting the wrong end of the stick as my knowledge of C++ (as opposed to C) is pretty sketchy.



Edited 1 time(s). Last edit at 04/18/2010 06:00PM by chris.
Re: CFile
April 18, 2010 06:19PM
Found it out, CFile was an included class but wasn't compiled with the code due to a nondefined variable.
Thanks for the reply tho!
Re: CFile
April 18, 2010 06:28PM
Now getting undefined reference to `access' (function).

c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:468: undefined reference to `access'
c:/devkitPro/projects/stratagus-2.2.4/source/iolib.cpp:473: undefined reference to `access'
script.o: In function `LoadCcl()':
c:/devkitPro/projects/stratagus-2.2.4/source/script.cpp:2557: undefined reference to `access'
collect2: ld returned 1 exit status

EDIT:
access() is an os function to read file properties.

This method uses the real uid/gid to test for access to path. Note that most operations will use the effective uid/gid, therefore this routine can be used in a suid/sgid environment to test if the invoking user has the specified access to path.

I guess it can be removed or replaced.

EDIT:

Replaced with fopen function



Edited 2 time(s). Last edit at 04/18/2010 07:54PM by Kajos.
Re: CFile
April 18, 2010 09:15PM
I compiled everything successfully, but the dol simply reboots to the homebrew channel. What can I do to check what's happening? Do I need Dolphin for this?
Re: CFile
April 19, 2010 05:01AM
The trick that I use is to add file access to the project and then dump out text to the file at various points in the project to see where it is getting and where it is not getting.

So basically I create a file on my SD card called debug.txt (or something similar) and the add, to my program, a function that takes a string input, opens the debug.txt file for appending, writes the string input to the file and closes the file. Don't forget to make sure that your FAT system is initialized. Then you can use this function throughout your code to dump messages to trace your flow. You can even go a step further and make these function calls run based on the value of a variable so that you can easily turn this tracing on and off.

Please keep in mind, however, that this method is time consuming so if you have timing related code then this process won't work because the file accesss will throw off your timing.
Sorry, only registered users may post in this forum.

Click here to login