We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

CodeWarrior linking issue

Oleg
Expert
Hello All,

I am very newbie on a Mac platform and CodeWarrior compiler.
CW just arrived yeaterday. Though I have coped and have
compiled one of my projects to try ( and it works ) but I can not
understand a linker issue. ( API 6.1 )

I actively use STL. At linking I got one error like this:
Link Error: undefined std::tr1::detail::shared_ptr_deleter_common.....

If I add the MSL_C++_PPC.Lib library the error gone, however then I
got numerous warnings like:
Link Warning: ignored std::clog (data) in MSL_C++_PPC.Lib
Previouly defined in GSCppRuntimeLib

As it is warnings the Addon is linked and works (not tested), but I am
not sure that it is correct. Except for that I have same warnings about
GS::GSException::__vt from GeometryLib and GSRootLib
( by the way the warnings exist if compile API Geometry_Test example
too ).

Anybody can direct me for a right way or explain linking and library
nuances.
May be any options of the compiler, the link order, added libraries or
may be it is usual stuff and is not "dangerous".
I remember Ralph Wessel told about necessity to recompile MSL. I yet
have not do it.

PS: And one another Mac specific question.
What function will open some page on default web browser like
ShellExecute on Windows.
8 REPLIES 8
Akos Somorjai
Graphisoft
Graphisoft
Oleg wrote:
I actively use STL. At linking I got one error like this:
Link Error: undefined std::tr1::detail::shared_ptr_deleter_common.....

If I add the MSL_C++_PPC.Lib library the error gone, however then I
got numerous warnings like:
Link Warning: ignored std::clog (data) in MSL_C++_PPC.Lib
Previouly defined in GSCppRuntimeLib
Hi Oleg,

This is a serious issue you bumped into. Basically, you'll have to use the headers which came with CodeWarrior 8 to get STL link correctly. Metrowerks will send you the CW 8 CD for free if you own CW 9, just send a letter to MWRon@metrowerks.com. After you install the old version, update it to 8.3 through the web.

The problem was that ArchiCAD 9 was compiled with MWerks compiler from the CW 9 package, whereas the headers and runtime libraries were from the CW 8.3 package, so you'll have to use the same files. Unfortunately, we cannot redistribute the CW 8.3 headers

Also, when you compile your project with STL, specify the following in the C/C++ Preprocess pane:
#define _MSL_NO_LOCALE
#define _MSL_MULTITHREAD
#define TARGET_API_MAC_CARBON 1
That would solve the STL compilation and linking issue.

Oleg wrote:
PS: And one another Mac specific question.
What function will open some page on default web browser like
ShellExecute on Windows.
Here you go. The parameter is a unicode string.
bool	RunBrowser (const GS::UniString& url)
{
	CFURLRef cfurl = CFURLCreateWithBytes (kCFAllocatorDefault, reinterpret_cast<const UInt8*> (static_cast<const UniChar*> (url.ToUStr ())), url.GetLength () * sizeof(UniChar), kCFStringEncodingUnicode, NULL);
	OSStatus status = ::LSOpenCFURLRef (cfurl, NULL);
	CFRelease (cfurl);

	return (status == noErr);
}
HTH,

Akos
Karl Ottenstein
Moderator
Akos wrote:
CFURLRef cfurl = CFURLCreateWithBytes (kCFAllocatorDefault, reinterpret_cast<const UInt8*> (static_cast<const UniChar*> (url.ToUStr ())), url.GetLength () * sizeof(UniChar), kCFStringEncodingUnicode, NULL);
Of course! Why didn't I think of that!

Karl
One of the forum moderators
AC 28 USA and earlier   •   macOS Sonoma 14.7.1, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
TomWaltz
Participant
Why didn't I think of that!
Wow, I must really be off today. I didn't think of that either!
Tom Waltz
Oleg
Expert
Akos wrote:
This is a serious issue you bumped into.
Akos
Thanks Akos.

Bad news . I own CW 9.0 and I shall write to the email for the 8.0 CD. However it is so long while it will arrive to Russia. I shall experiment more. As STL basically inlined I think the reason is std::string.
May be i will try remove std::string from projects or I shall try to play with STLPort if it will compile on CW9 (I did not try, just idea). Actually my two projects work, but my doubts have remained.

PS: Also thank you for the LSOpenCFURLRef. I have found it already earlier an my code is same except I used ASCII string. It works.
Oleg
Expert
To finish the thread by happyend.
Ron from Metrowerks was so kind and has sent me the headers I was required. Now I have linked it without warnings.
( Except duplication of GS:: Exception::vt in GSGeometry and GSRootLib, but API example has the same warnings, I think it is OK )

Akos thank you again for the support.
Akos Somorjai
Graphisoft
Graphisoft
Oleg wrote:
To finish the thread by happyend.
Ron from Metrowerks was so kind and has sent me the headers I was required. Now I have linked it without warnings.
( Except duplication of GS:: Exception::vt in GSGeometry and GSRootLib, but API example has the same warnings, I think it is OK )

Akos thank you again for the support.
MWRon is one of the best support person in the world. We are also getting great support from him.

The warnings come because the virtual destructor of the GS::Exception class is implemented as an inline function. It didn't cause any problems so far, so I think you dont' have to worry about that.

You're welcome...

Akos
Ralph Wessel
Mentor
Oleg wrote:
I actively use STL. At linking I got one error like this:
Link Error: undefined std::tr1::detail::shared_ptr_deleter_common.....

If I add the MSL_C++_PPC.Lib library the error gone, however then I
got numerous warnings like:
Link Warning: ignored std::clog (data) in MSL_C++_PPC.Lib
Previouly defined in GSCppRuntimeLib

Oleg,

Sorry, I haven't been following ACTalk for a while and missed this. It seems you already have a solution - which is great - but I may as well add my solution to the discussion.

I don't use the GS Runtime libs at all in my projects. My understanding is that they are simply a recompilation of the standard MSL library (MSL_All_Carbon.Lib) with the appropriate settings for an ArchiCAD add-on, e.g. 'enums always int' set. I rebuilt them myself and use all the latest headers etc provided with CW 9. I get no warnings in compilation or linking.

I would be interested to know if Akos has any comments on this approach.
Ralph Wessel BArch
Software Engineer Speckle Systems
Akos Somorjai
Graphisoft
Graphisoft
Ralph wrote:
I don't use the GS Runtime libs at all in my projects. My understanding is that they are simply a recompilation of the standard MSL library (MSL_All_Carbon.Lib) with the appropriate settings for an ArchiCAD add-on, e.g. 'enums always int' set. I rebuilt them myself and use all the latest headers etc provided with CW 9. I get no warnings in compilation or linking.

I would be interested to know if Akos has any comments on this approach.
Yes, you are safe. I would still recommend using the same environment, i.e. compile the MSL headers with:
#define _MSL_NO_LOCALE 
#define _MSL_MULTITHREAD 
#define TARGET_API_MAC_CARBON 1
Another issue which you might bump into is the newline character problem ('\r' vs '\n'). Coming from the old Mac OS 9 world ArchiCAD still has some places where line ends matter. CW9 has the 'MPW newline' flag removed, which might crash our code, hence we sticked with the 8.3 headers.


We'll clean up this issue in the next major version.


HTH,

Akos

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!