Author Topic: first use of C::B >> undefined references  (Read 11702 times)

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
first use of C::B >> undefined references
« on: February 23, 2006, 09:38:20 pm »
I started a project on a foreign IDE (Dev-C++) with "libzip" on MinGW. The project compiled in the IDE.

Now I tried to migrate the project to C::B. The compiler runs. It is ok.
But the linker says:

<linker>
Compiling: libzip\lib\zip_unchange_data.c
Linking console executable: E:\Garage\projekte\OctopusBackup\OctopusBackup.exe
.objs\libzip\lib\zip_fread.o:zip_fread.c:(.text+0x10d): undefined reference to `crc32'
.objs\libzip\lib\zip_fread.o:zip_fread.c:(.text+0x166): undefined reference to `inflate'
.objs\libzip\lib\zip_fread.o:zip_fread.c:(.text+0x201): undefined reference to `crc32'
.objs\libzip\lib\zip_close.o:zip_close.c:(.text+0xd5c): undefined reference to `crc32'
.objs\libzip\lib\zip_close.o:zip_close.c:(.text+0xdd7): undefined reference to `deflateInit2_'
.objs\libzip\lib\zip_close.o:zip_close.c:(.text+0xe8d): undefined reference to `deflateEnd'
.objs\libzip\lib\zip_close.o:zip_close.c:(.text+0xef4): undefined reference to `crc32'
.objs\libzip\lib\zip_close.o:zip_close.c:(.text+0xf1b): undefined reference to `deflate'
.objs\libzip\lib\zip_close.o:zip_close.c:(.text+0x101c): undefined reference to `deflateEnd'
.objs\libzip\lib\zip_error_strerror.o:zip_error_strerror.c:(.text+0xae): undefined reference to `zError'
.objs\libzip\lib\zip_error_to_str.o:zip_error_to_str.c:(.text+0x81): undefined reference to `zError'
.objs\libzip\lib\zip_fclose.o:zip_fclose.c:(.text+0x1a): undefined reference to `inflateEnd'
.objs\libzip\lib\zip_fopen_index.o:zip_fopen_index.c:(.text+0x3ba): undefined reference to `inflateInit2_'
.objs\libzip\lib\zip_fopen_index.o:zip_fopen_index.c:(.text+0x684): undefined reference to `crc32'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 22 seconds)
0 errors, 0 warnings
</linker>

I am not sure what is wrong, and where I have to search for the error.

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
Re: first use of C::B >> undefined references
« Reply #1 on: February 23, 2006, 09:39:10 pm »
sorry...

I use C::B (rc2) on win98se with gnu gcc

sethjackson

  • Guest
Re: first use of C::B >> undefined references
« Reply #2 on: February 23, 2006, 09:41:16 pm »
You do not have the correct libs linked in.... You need to link in zlib. That would be wxzlib if you use wxWidgets.....

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
Re: first use of C::B >> undefined references
« Reply #3 on: February 23, 2006, 09:54:21 pm »
In the C::B I do not find any zlib-files.

I got a own zlib release from the website zlib.org. In my project settings(default target) i added the lib-directory.
But it has no effect. Why?

I added a lib explicite in the linker options. First I tried "zlib.lib". But then the exe asked for "zlib1.dll". Now I am using "libz.a". You know why there are so many different "versions" (?) for zlib?

On my Dev-C++ IDE I only added the lib-directory to the project and all the other things worked.

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
Re: first use of C::B >> undefined references
« Reply #4 on: February 23, 2006, 09:55:15 pm »
> That would be wxzlib if you use wxWidgets.....

What is this? I know what wxWidgets are, but what have this to do with zlib? I can not find any wxzlib-file on my system.

sethjackson

  • Guest
Re: first use of C::B >> undefined references
« Reply #5 on: February 23, 2006, 09:57:47 pm »
> That would be wxzlib if you use wxWidgets.....

What is this? I know what wxWidgets are, but what have this to do with zlib? I can not find any wxzlib-file on my system.

Basically if you were linking a wx app, and you had a static build of wxWidgets you would need to link in wxzlib to solve the above problems...... I see you aren't using wx though.... Hmm could you try a nightly build????

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: first use of C::B >> undefined references
« Reply #6 on: February 23, 2006, 10:02:47 pm »
Quote
Hmm could you try a nightly build????
That will not make anything better. If you don't link properly, then it will not work either way.

1. Make sure that you actually have the zlib library. "Have" means above all that it has to be in a place where the linker will find it.
2. One way to assure that this is the case is to put it into your lib folder (that one is usually in the linker's search path, if not, add it).
3. Add zlib to "Link libraries", the IDE will automatically replace that with the correct file name (libzlib.a in this case).

EDIT:
As a general sidenote, you should set your compiler options to "full command line" when encountering a problem.
The string "Linking console executable" does not tell anything useful. However, the full commandline usually shows the source of the problem right away.
« Last Edit: February 23, 2006, 10:06:02 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
Re: first use of C::B >> undefined references
« Reply #7 on: February 23, 2006, 10:19:13 pm »
> nightly builds

Not possible at this time, because that are unicode builds that does not run under Win98se. But I work on it.

> 1. Make sure that you actually have the zlib library.

Yes, I have.

> 2. One way to assure that this is the case is to put it into your lib
> folder (that one is usually in the linker's search path, if not, add it).
> 3. Add zlib to "Link libraries", the IDE will automatically replace
> that with the correct file name (libzlib.a in this case).

I thougt have to put a concret lib-file in "link libraries". No I tried it your way: "zlib" in "link libraries" and adding the zlib-lib-directory to the linker search-path. Now the linker links zlib.lib I do not want, because I need a zlib1.dll for it.

Actualy I deleted the lib-search path and added the lib "libz.a" directly to "link libraries". It worked. The project links and starts without asking for any DLLs.

It is quite complicaded and confusing me. Thanks for your help!



EDIT:
As a general sidenote, you should set your compiler options to "full command line" when encountering a problem.
The string "Linking console executable" does not tell anything useful. However, the full commandline usually shows the source of the problem right away.

GLfoat

  • Guest
Re: first use of C::B >> undefined references
« Reply #8 on: February 23, 2006, 10:21:31 pm »
i also do have this probrem with liblary and linker
i do not understand why i have to learn so much about complier.
why do i need a linker when i already have a compiler.
a good ide as coldbocks should do that for me , isn't it ?
could it not find for me, it would be much easier then !
thanks for all your help !


Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: first use of C::B >> undefined references
« Reply #9 on: February 23, 2006, 10:27:32 pm »
My fault... the library is called libz.a, so you obviously have to type z into "Link libraries"...
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MoonKid

  • Almost regular
  • **
  • Posts: 180
Re: first use of C::B >> undefined references
« Reply #10 on: February 23, 2006, 10:31:16 pm »
why do i need a linker when i already have a compiler.
a good ide as coldbocks should do that for me , isn't it ?

Do I hear some sarcasm in your post?

But you are right. Handling of the compiler and linker is much harder and complexer than in MSVC60.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: first use of C::B >> undefined references
« Reply #11 on: February 23, 2006, 10:38:51 pm »
search in the forum, I think last week or 2 weeks ago, I somewhere posted a topic with a link to a nightly (at that time) for win98 (so an ansi build). I will create a new one this weekend.

Here is a link to the most recent one I think :
http://download.berlios.de/codeblocks/CB_20060217_rev2025_win32_ansi_.7z

kind regards,
Lieven

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: first use of C::B >> undefined references
« Reply #12 on: February 23, 2006, 10:39:44 pm »
why do i need a linker when i already have a compiler.
a good ide as coldbocks should do that for me , isn't it ?

Do I hear some sarcasm in your post?

But you are right. Handling of the compiler and linker is much harder and complexer than in MSVC60.

that is not true, it is just the same, you need the lib, and you need to specify it to the linker, and off course the linker needs to find it.

takeshimiya

  • Guest
Re: first use of C::B >> undefined references
« Reply #13 on: February 23, 2006, 11:46:43 pm »
Actually, anyone ever tried the byo's plugin "Library Finder" ? :lol: