Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Wicksmacker on November 03, 2008, 07:38:49 pm

Title: Problem trying to build project
Post by: Wicksmacker on November 03, 2008, 07:38:49 pm
Hello, I had my project working before I reformat.
Now I get the following errors:

Quote
mingw32-g++.exe: ..\..\..\..\..\Program Files\Lua\5.1\lib\lua5.1.lib: No such file or directory
mingw32-g++.exe: ..\..\..\..\..\Program Files\Lua\5.1\lib\lua51.lib: No such file or directory

I added these files in the Linker settings tab of Build Options.
The files/directory are definitely there.
Why do I keep getting this error?
Title: Re: Problem trying to build project
Post by: thomas on November 04, 2008, 12:14:13 pm
Probably a problem with the ..\..\..\..\..  - easy to get those wrong.
I'd try adding the path to the linker's search directories, preferabbly as an absolute path stored in a user variable (that's what they're for). Then the library can be accessed by its name only, much more comfortably and failsafe.
Title: Re: Problem trying to build project
Post by: Wicksmacker on November 07, 2008, 07:06:09 pm
That fixed the problem.  Thank you very much, Thomas.
Title: Re: Problem trying to build project
Post by: Tupac on November 07, 2008, 10:28:39 pm
I have a similar problem working a project in Code::Blocks ........ Do you have any suggestion?

These are the Error messages:

Quote
C:\project\metis-4.0\Lib\util.c           Undefined reference to "srand48"
C:\project\metis-4.0\Lib\initpart.c     Undefined reference to "drand48"

The Lib's paths have been previously declared in the Compiler and Linker Search Directories.
The files requested exist all of them: util.c & util.o - and - initpart.c & initpart.o
The standard library #include <stdlib.h> is declared inside of these C files (for using srand48 and drand48).

Previously the Cholmod and Metis math tools have been processed without errors using the Make sentence of the Cygwin tool.
But I see that these errors are referred to Standard Library functions!

Look foward any help.
Thanks.
Title: Re: Problem trying to build project
Post by: thomas on November 08, 2008, 05:30:36 pm
Not related to the previous problem, as in your case it's not a linker path that's wrong, but missing symbols, i.e. you're not linking the object file or library containing srand48 and drand48 at all.
I'm not sure if either Cygwin or MinGW support drand48 at all, though... so you might need to compile drand48.c or something...
Title: Re: Problem trying to build project
Post by: Tupac on November 08, 2008, 09:22:49 pm
Quote
Not related to the previous problem, as in your case it's not a linker path that's wrong, but missing symbols, i.e. you're not linking the object file or library containing srand48 and drand48 at all.
I'm not sure if either Cygwin or MinGW support drand48 at all, though... so you might need to compile drand48.c or something...

Thank you Thomas. I appretiate your advices. I have to tell you that I'm far not an expert in C::B C++ language, but I'm trying, so I wonder if you could be more specific and detailed about how can I do this issues in my CB environment.

Particulary I have two questions:

1. How can I do link these libraries in my project (what symbols do you refer?), because I can see that the "util.o" and "initpart.o" files exist!

2. Of course maybe these files are not good compiled. I wonder if these "srand48" and "drand48" commands work in a Windows Vista environment?

I have read that these commands work only in Linux not in Windows, but it is hard to think that these Metis and Cholmod libraries for Windows (that I downloaded) included so obvious mistake.

I look foward your suggestions.
Thank you very much.

Tupac
Title: Re: Problem trying to build project
Post by: thomas on November 10, 2008, 10:22:31 am
srand48/drand48 are part of the single Unix specification, so you're (almost) right. Linux is not Unix, but close enough :)
However, as it's only a library function, there is a chance that Cygwin includes it... MinGW pretty sure doesn't, I'm quite certain.

What you can do to get it working is to either replace drand48() with the normal rand() function (and similarly for srand()) via a #define hack, if you can afford having a lower quality random number generator, or you have to provide that missing function yourself.
Chances are that if whatever project you try to compile is cross-platform and it already includes a drand48.c file. If it doesn't, you can find an implementation via Koders or Google code search. Compile that file, and link it. In principle, you can use any PRNG function, as long as you keep the function's signature intact.