You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Linker moans about crt1.o when custom dylib used

Hi.

I've recently started with Xcode, having otherwise been proficient with C/C++ for some time.

I have a custom dynamic library, libftd2xx.dylib, from ftdichip.com, which implements communication with USB hardware from same company. I have no trouble linking and using this library using gcc at the console level. EG:...

gcc test.c -lftd2xx -o test

... works just fine.

But I've now started a simple Objective-C Cocoa project and am trying to link in libftd2xx. That's where it all goes wrong. If this library is linked (using any one of several methods in Xcode) the linker fails with, none other than, check this out!...:

ld: could not find entry point "start" (perhaps missing crt1.o)

This is VERY odd to me. Why should simply linking in a dynamic library cause such a catastrophic linker error? If I remove "-lftd2xx" from "Other Linker Flags" in project preferences and comment references to external functions therein, then the application compiles and runs just fine!

I'm totally perplexed by this and, sadly, Googling all day yesterday hasn't shed any light on the problem.

If it helps, here's some otool -L output for the library in question:

% otool -L /usr/local/lib/libftd2xx.dylib
/usr/local/lib/libftd2xx.dylib:
/usr/local/lib/libftd2xx.0.1.0.dylib (compatibility version 0.1.0, current version 0.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.1.6)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 368.27.0)

Many, many, thanks for any assistance you may be able to provide!

Kind Regards,

Bryan.

MacBook, Mac OS X (10.5), 2GB RAM

Posted on Mar 18, 2008 5:56 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 18, 2008 7:24 PM

gruvin wrote:
But I've now started a simple Objective-C Cocoa project and am trying to link in libftd2xx. That's where it all goes wrong. If this library is linked (using any one of several methods in Xcode) the linker fails with, none other than, check this out!...:

ld: could not find entry point "start" (perhaps missing crt1.o)

This is VERY odd to me. Why should simply linking in a dynamic library cause such a catastrophic linker error? If I remove "-lftd2xx" from "Other Linker Flags" in project preferences and comment references to external functions therein, then the application compiles and runs just fine!


Can you say specifically what methods you used to link the file? I just downloaded the driver and tried the "Simple" sample program and it links fine in both gcc and Xcode. I selected the "Frameworks" group, right-clicked, chose "Add existing files" and added "libftd2xx.dylib".

In any event, you are going to have trouble with this file and Cocoa. You are going to have to isolate all the ftd2xx code in C files. You can't use them with objective C due to such gems as:

#ifndef _WINDOWS
#include <pthread.h>
#define WINAPI
#endif

and

#ifndef _WINDOWS
#include "WinTypes.h"

Both WinTypes.h and Objective-C have different definitions for BOOL. This is not a critical error, but don't try including 'ftd2xx.h" in any Objective-C source file. You'll need some C wrappers.
8 replies
Question marked as Top-ranking reply

Mar 18, 2008 7:24 PM in response to gruvin

gruvin wrote:
But I've now started a simple Objective-C Cocoa project and am trying to link in libftd2xx. That's where it all goes wrong. If this library is linked (using any one of several methods in Xcode) the linker fails with, none other than, check this out!...:

ld: could not find entry point "start" (perhaps missing crt1.o)

This is VERY odd to me. Why should simply linking in a dynamic library cause such a catastrophic linker error? If I remove "-lftd2xx" from "Other Linker Flags" in project preferences and comment references to external functions therein, then the application compiles and runs just fine!


Can you say specifically what methods you used to link the file? I just downloaded the driver and tried the "Simple" sample program and it links fine in both gcc and Xcode. I selected the "Frameworks" group, right-clicked, chose "Add existing files" and added "libftd2xx.dylib".

In any event, you are going to have trouble with this file and Cocoa. You are going to have to isolate all the ftd2xx code in C files. You can't use them with objective C due to such gems as:

#ifndef _WINDOWS
#include <pthread.h>
#define WINAPI
#endif

and

#ifndef _WINDOWS
#include "WinTypes.h"

Both WinTypes.h and Objective-C have different definitions for BOOL. This is not a critical error, but don't try including 'ftd2xx.h" in any Objective-C source file. You'll need some C wrappers.

Mar 18, 2008 8:01 PM in response to etresoft

Hi. Thanks for the reply.

{quote}Can you say specifically what methods you used to link the file? I just downloaded the driver and tried the "Simple" sample program and it links fine in both gcc and Xcode. I selected the "Frameworks" group, right-clicked, chose "Add existing files" and added "libftd2xx.dylib".{quote}

I tried your method also, same result. My methods include that one (adding existing files to project) and also adding
-lftd2xx
to "Other Linker Flags" in Project Settings.

I noticed the BOOL conflict and simply commented out the WinTypes.h definition. I can address all those problem later, once I get the think to link in the first place.

The specific functions I am referencing/calling really amount to "any of them". But for completelness,
here's an actual copy of my code in question:


// file: Programmer.m
#import "Programmer.h"
#include "ftd2xx.h"
@implementation Programmer
@synthesize channel;
@synthesize txbyte;
- (int)sendByte {
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
int iport = 1; // channel B
ftStatus = FT_Open(iport, &ftHandle);
if(ftStatus != FT_OK) {
// printf("FT_Open(%d) failed = %d ", iport, ftStatus);
return(1);
}
// enable BitBlast Asynchronous mode by setting BitMode control bit 0 (Control = 0x01)
// set bit 7 as input, all others to output
if ((ftStatus = FT_SetBitMode(ftHandle, 0x7F, 0x01)) != FT_OK) {
// printf("Failed to set bit mode ");
return(2);
}
if(ftHandle != NULL) {
FT_Close(ftHandle);
ftHandle = NULL;
}

return(0);
}
@end


Since the library linked OK for you, I'm now thinking I might have to uninstall the /Developer tree completely and start over. Maybe something is messed up in there? But not yet, I guess.

Bryan.

Mar 19, 2008 6:28 AM in response to gruvin

I'm sorry you went to the trouble. I wouldn't have thought there was a problem on the Apple side at all. You also don't want to hack up the WinTypes.h file. That is a system delivered file and shouldn't be messed with.

Make sure you have a good Xcode install. Make sure WinTypes.h is in its original condition. Then try it again. I just created a Cocoa application and put the library in the frameworks group. Because of the BOOL problem, I did have to main main.m to main.c, so it really isn't a Cocoa app anymore. You may have to do a "Clean all targets" before building too.

Mar 19, 2008 12:45 PM in response to etresoft

{quote:title=etresoft wrote:}
You also don't want to hack up the WinTypes.h file. That is a system delivered file and shouldn't be messed with.{quote}

All I've done is comment out the BOOL definition. This will have no harmful affects as I'm not using the construct anywhere in my code anyway. Also, WinTypes.h is not part of OS X - not mine anyway. It is supplied by the vendor (sourced from Microsoft?) solely for data structure compatibility with the driver they originally wrote in Windows. (Shame on them! :P)

{quote}Make sure you have a good Xcode install.{quote}
Seems to be OK. Works for everything else I've tried.

{quote}Because of the BOOL problem, I did have to main main.m to main.c, so it really isn't a Cocoa app anymore.{quote}

Err... but doing that completely avoids the whole issue. The goal here is to create a Cocoa application. I tried it anyway, but got the expected 300+ compiler errors due to all the Objective-C syntax that makes no sense to gcc when it's trying to compile in ANSI mode, I presume. shrug

{quote}You may have to do a "Clean all targets" before building too.{quote}

Done that many, many times. Always do when there's some uncertainty.

I'd be interested to see the actual compiler output log from your working build. Maybe I'll see something there to give a missing clue? Though with main.m renamed to main.c, I doubt it will mean much unfortunately. Here's mine for the sake of it:


Checking Dependencies
CompileC build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/main.o "/Users/bryan/Xcode Projects/Pixster/main.m" normal i386 objective-c com.apple.compilers.gcc.4_0
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Pixster.hmap" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" "-I/Users/bryan/Xcode Projects/Pixster/build/Debug/include" "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/DerivedSources" -isysroot /Developer/SDKs/MacOSX10.5.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/PixsterPrefix-arvpmawmbqmzkhcmxsgrardhnyhe/PixsterPrefix.pch -c "/Users/bryan/Xcode Projects/Pixster/main.m" -o "/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/main.o"
Ld "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/MacOS/Pixster" normal i386
mkdir "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/MacOS"
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -o "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/MacOS/Pixster" "-L/Users/bryan/Xcode Projects/Pixster/build/Debug" "-L/Users/bryan/Xcode Projects/Pixster" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" -filelist "/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/Pixster.LinkFileList" -framework Cocoa -lftd2xx -arch i386 -nostdlib -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
ld: could not find entry point "start" (perhaps missing crt1.o)
collect2: ld returned 1 exit status




The only other thing I can think of is OS and Xcode versions. I'm on OS X v10.5.2 using Xcode v3.0.

Thanks for your time.

Bryan.

Mar 19, 2008 12:52 PM in response to gruvin

UPDATE: I've also just tried cross-compiling against "Mac OS X 10.4 (Universal)". Same problem persists.

And here's the full build output log, after a Clean All Targets, for what it's worth.


Checking Dependencies
Processing "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/Info.plist" Info.plist
mkdir "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents"
cd "/Users/bryan/Xcode Projects/Pixster"
<com.apple.tools.info-plist-utility> "/Users/bryan/Xcode Projects/Pixster/Info.plist" -genpkginfo "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/PkgInfo" -expandbuildsettings -o "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/Info.plist"
CpResource build/Debug/Pixster.app/Contents/Resources/English.lproj/MainMenu.nib English.lproj/MainMenu.nib
mkdir "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/Resources/English.lproj"
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks "/Users/bryan/Xcode Projects/Pixster/English.lproj/MainMenu.nib" "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/Resources/English.lproj"
CpResource build/Debug/Pixster.app/Contents/Resources/English.lproj/InfoPlist.strings English.lproj/InfoPlist.strings
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks "/Users/bryan/Xcode Projects/Pixster/English.lproj/InfoPlist.strings" "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/Resources/English.lproj"
ProcessPCH /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/PixsterPrefix-arvpmawmbqmzkhcmxsgrardhnyhe/PixsterPrefix.pch.gch Pixster_Prefix.pch normal i386 objective-c com.apple.compilers.gcc.4_0
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -x objective-c-header -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Pixster.hmap" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" "-I/Users/bryan/Xcode Projects/Pixster/build/Debug/include" "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/DerivedSources" -isysroot /Developer/SDKs/MacOSX10.5.sdk -c "/Users/bryan/Xcode Projects/Pixster/Pixster_Prefix.pch" -o /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/PixsterPrefix-arvpmawmbqmzkhcmxsgrardhnyhe/PixsterPrefix.pch.gch
CompileC build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/main.o "/Users/bryan/Xcode Projects/Pixster/main.m" normal i386 objective-c com.apple.compilers.gcc.4_0
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Pixster.hmap" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" "-I/Users/bryan/Xcode Projects/Pixster/build/Debug/include" "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/DerivedSources" -isysroot /Developer/SDKs/MacOSX10.5.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/PixsterPrefix-arvpmawmbqmzkhcmxsgrardhnyhe/PixsterPrefix.pch -c "/Users/bryan/Xcode Projects/Pixster/main.m" -o "/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/main.o"
CompileC build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/Programmer.o "/Users/bryan/Xcode Projects/Pixster/Programmer.m" normal i386 objective-c com.apple.compilers.gcc.4_0
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Pixster.hmap" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" "-I/Users/bryan/Xcode Projects/Pixster/build/Debug/include" "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/DerivedSources" -isysroot /Developer/SDKs/MacOSX10.5.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/PixsterPrefix-arvpmawmbqmzkhcmxsgrardhnyhe/PixsterPrefix.pch -c "/Users/bryan/Xcode Projects/Pixster/Programmer.m" -o "/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/Programmer.o"
CompileC build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/PixsterController.o "/Users/bryan/Xcode Projects/Pixster/PixsterController.m" normal i386 objective-c com.apple.compilers.gcc.4_0
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Pixster.hmap" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" "-I/Users/bryan/Xcode Projects/Pixster/build/Debug/include" "-I/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/DerivedSources" -isysroot /Developer/SDKs/MacOSX10.5.sdk -include /Library/Caches/com.apple.Xcode.501/SharedPrecompiledHeaders/PixsterPrefix-arvpmawmbqmzkhcmxsgrardhnyhe/PixsterPrefix.pch -c "/Users/bryan/Xcode Projects/Pixster/PixsterController.m" -o "/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/PixsterController.o"
Ld "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/MacOS/Pixster" normal i386
mkdir "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/MacOS"
cd "/Users/bryan/Xcode Projects/Pixster"
/Developer/usr/bin/gcc-4.0 -o "/Users/bryan/Xcode Projects/Pixster/build/Debug/Pixster.app/Contents/MacOS/Pixster" "-L/Users/bryan/Xcode Projects/Pixster/build/Debug" "-L/Users/bryan/Xcode Projects/Pixster" "-F/Users/bryan/Xcode Projects/Pixster/build/Debug" -filelist "/Users/bryan/Xcode Projects/Pixster/build/Pixster.build/Debug/Pixster.build/Objects-normal/i386/Pixster.LinkFileList" -framework Cocoa -lftd2xx -arch i386 -nostdlib -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
ld: could not find entry point "start" (perhaps missing crt1.o)
collect2: ld returned 1 exit status

Mar 19, 2008 2:24 PM in response to gruvin

It will be a couple of hours before I can get back to my Mac to look at it again. Would it be possible to post your code somewhere? That would be better than the example files that came with the driver.

Also, see if you have better luck with a release build. Dynamic libraries do funky things with debug builds.

I have the same OS and Xcode version that you do.

Mar 19, 2008 3:16 PM in response to etresoft

Hello again.

Well, go figure. In desparation, I started a fresh project and put the pieces together just as I had in the previous project. This time I clicked the build button for just about every step I took. Ultimately, I got right to the end and the program still compiles, links and runs perfectly!!

I'm flummoxed. I mean, ***? :P I've looked and looked but still can't find any real difference between the two projects. \ sigh

Thanks so much for your time etresoft.

Bryan.

Linker moans about crt1.o when custom dylib used

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.