Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-09

Linking problem

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ivo Steinmann

Hello all

I tried to link libmodplug.so but get this error:

/usr/lib/libmodplug.so: undefined reference to `operator new[](unsigned int)'
/usr/lib/libmodplug.so: undefined reference to `operator delete(void*)' /usr/lib/libmodplug.so: undefined reference to `operator delete[](void*)' /usr/lib/libmodplug.so: undefined reference to `operator new(unsigned int)'

do I have to link another library also (something like libstd) or is there a way that I can define those function in my application? Im a littlebit confused about "operator"

greets
Ivo

Reply by email

Flávio Etrusco
to Ivo Steinmann

I'd guess this library is exporting (and importing) in C++ symbols and thus can't be linked with FPC?

-Flávio

Ivo Steinmann wrote 20 lines
Hello all I tried to link libmodplug.so but get this error: /usr/lib/libmodplug.so: undefined reference to `operator new[](unsigned int)' /usr/lib/libmodplug.so: undefined reference to `operator delete(void*)' /usr/lib/libmodplug.so: undefined reference to `operator delete[](void*)' /usr/lib/libmodplug.so: undefined reference to `operator new(unsigned int)' do I have to link another library also (something like libstd) or is there a way that I can define those function in my application? Im a littlebit confused about "operator" greets Ivo _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Daniël Mantione
to Flávio Etrusco

Op Sat, 23 Sep 2006, schreef Flávio Etrusco:

I'd guess this library is exporting (and importing) in C++ symbols and thus can't be linked with FPC?

Linking is always possible, wether you can call it is another matter. I don't know with library you need, but it might be libstdc++.

Daniël

Reply by email

peter green
to Ivo Steinmann: Hello all I tried to link libmodplug.so but get this error: /usr/lib/libmodplug.so:…

i'm guessing (i could be wrong) that you need to link in libstdc++

Show quoted text 29 lines
-----Original Message----- From: Behalf Of Ivo Steinmann Sent: 23 September 2006 19:48 To: FPC developers' list Subject: [fpc-devel] Linking problem Hello all I tried to link libmodplug.so but get this error: /usr/lib/libmodplug.so: undefined reference to `operator new[](unsigned int)' /usr/lib/libmodplug.so: undefined reference to `operator delete(void*)' /usr/lib/libmodplug.so: undefined reference to `operator delete[](void*)' /usr/lib/libmodplug.so: undefined reference to `operator new(unsigned int)' do I have to link another library also (something like libstd) or is there a way that I can define those function in my application? Im a littlebit confused about "operator" greets Ivo _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Ivo Steinmann
to Ivo Steinmann: Hello all I tried to link libmodplug.so but get this error: /usr/lib/libmodplug.so:…
Ivo Steinmann wrote 16 lines
Hello all I tried to link libmodplug.so but get this error: /usr/lib/libmodplug.so: undefined reference to `operator new[](unsigned int)' /usr/lib/libmodplug.so: undefined reference to `operator delete(void*)' /usr/lib/libmodplug.so: undefined reference to `operator delete[](void*)' /usr/lib/libmodplug.so: undefined reference to `operator new(unsigned int)' do I have to link another library also (something like libstd) or is there a way that I can define those function in my application? Im a littlebit confused about "operator"

I found my own solution (and that's working for linux here). But I dont know if it's a bad idea to do it. linking libstdc++ leads to other problems here, so I cant do that. Flawless and me have got a unit that implements some parts of stdlibc++, so I took the functions above from this lib.

function cppNew(s: cint): pointer; cdecl; public; alias : '_Znaj'; alias
: '_Znwj';
begin
  GetMem(Result, s);
end;
procedure cppDelete(p: pointer); cdecl; public; alias : '_ZdlPv'; alias
: '_ZdaPv';
begin
  FreeMem(p);
end;

now it compiles and works without any problems. What do you think? dangerous? crazy? If you think it's a good idea, I would like to add a unti called fpcstdcpp or something like that. This unit defines other things also, like fdiv, etc...

-Ivo Steinmann

Reply by email

Christian Iversen
to Ivo Steinmann
Ivo Steinmann wrote 26 lines
Ivo Steinmann wrote: > Hello all > > I tried to link libmodplug.so but get this error: > > /usr/lib/libmodplug.so: undefined reference to `operator > new[](unsigned int)' > /usr/lib/libmodplug.so: undefined reference to `operator delete(void*)' > /usr/lib/libmodplug.so: undefined reference to `operator delete[](void*)' > /usr/lib/libmodplug.so: undefined reference to `operator new(unsigned > int)' > > do I have to link another library also (something like libstd) or is > there a way that I can define those function in my application? Im a > littlebit confused about "operator" I found my own solution (and that's working for linux here). But I dont know if it's a bad idea to do it. linking libstdc++ leads to other problems here, so I cant do that. Flawless and me have got a unit that implements some parts of stdlibc++, so I took the functions above from this lib. [...] now it compiles and works without any problems. What do you think? dangerous? crazy?

I don't think so. Since every call to new _must_ be matched by a call to delete, we can be sure that there are no special functions for clearing a pointer.

If you think it's a good idea, I would like to add a unti called fpcstdcpp or something like that. This unit defines other things also, like fdiv, etc...

I like it, that's why I made the original unit :D

Really, many things can compile with just a few simple functions (like those you used here).

Maybe we could use littlelibcpp.pas as a base for fpstdcpp.pas?

Regards, Christian Iversen

Reply by email

Christian Iversen
to Micha Nelissen
Micha Nelissen wrote 5 lines
Ivo Steinmann wrote: > now it compiles and works without any problems. What do you think? > dangerous? crazy? If you think it's a good idea, I would like to add a There is no difference on the ABI level of 'new' and 'new[]' ?

I think the reason there are two different operators, is because the names are mangled differently for consistency (because it _could_ very well have been important if it's the array version or not)

Of course, this makes it possible to try and use an array-optimized memory allocator for the []-cases.

Regards, Christian Iversen

Reply by email