Re: [fpc-devel] Linking problem
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. 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 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Linking problem
On Sunday 24 September 2006 11:02, Ivo Steinmann wrote: 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 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Linking problem
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[]' ? Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Linking problem
On Sunday 24 September 2006 19:52, Micha Nelissen wrote: 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 ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel