Xcode linker and blocks: Undefined symbol "___block_global_1" - xcode

I am trying to build an application in Xcode 3.2.4 and am getting the following linker error:
Undefined symbols:
"___block_global_1", referenced from:
___block_holder_tmp_1.120 in foobarbaz.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I'm at a loss to explain what I've done in my source file that might be causing the error. I do have a block that I am defining as a global variable, like so:
typedef void(^error_block_t)(NSError* error);
error_block_t error_handler_s = ^void(NSError* error)
{
//...
}
This block is defined in an empty namespace in the source (I'm compiling Objective-C++.) Everything compiles without error.
Update: Moving the block to be a local variable for the routine that references it is a viable (though not preferred) workaround.
What gives?

If the error_handler_s is not intended to be exported, you could make it static as another workaround.
namespace {
...
static error_block_t error_handler_s = ^void(NSError* error) { ... };
...
}
Otherwise, I believe this is a bug in gcc.

At this point I believe this issue to be a bug.

Related

LUFA with Eclipse but without Makefile

I want to use LUFA for my ATMEGA32U4 to communicate via CDC. So to start I created a project in Eclipse and imported the LUFA folder and the files for the Device VirtualSerial demo. The thing is, that I want to do that without using the makefile (mostly because I have never used makefiles before). Is that possible and what do I need to do? I have tried a lot, but I get errors all the time. Is there any instruction?
Thanks!
Sebastian
P.S.: Just to be clear. I want to use the "Managed Builder", so that I don´t have to do anything with the makefile, but Eclipse does that for me.
P.P.S.: I also tried http://www.fourwalledcubicle.com/files/LUFA/Doc/140928/html/_page__exporting_library.html
with AS7 and Eclipse, but it didn´t work with both.....
P.P.S.: When I try to build the project I get the error
'Building target: Test1.elf'
'Invoking: AVR C Linker'
avr-gcc -Wl,-Map,Test1.map -mmcu=atmega32u4 -o "Test1.elf" ./LUFA/Platform/UC3/Exception.o ./LUFA/Platform/UC3/InterruptManagement.o ./LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_R.o ./LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.o ./LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_RW.o ./LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/PipeStream_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.o ./LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.o ./LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_R.o ./LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.o ./LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_RW.o ./LUFA/Drivers/USB/Core/UC3/Template/Template_Pipe_RW.o ./LUFA/Drivers/USB/Core/UC3/Device_UC3.o ./LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.o ./LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.o ./LUFA/Drivers/USB/Core/UC3/Host_UC3.o ./LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.o ./LUFA/Drivers/USB/Core/UC3/Pipe_UC3.o ./LUFA/Drivers/USB/Core/UC3/USBController_UC3.o ./LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.o ./LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.o ./LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.o ./LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.o ./LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.o ./LUFA/Drivers/USB/Core/AVR8/Device_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/Host_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.o ./LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.o ./LUFA/Drivers/USB/Core/ConfigDescriptors.o ./LUFA/Drivers/USB/Core/DeviceStandardReq.o ./LUFA/Drivers/USB/Core/Events.o ./LUFA/Drivers/USB/Core/HostStandardReq.o ./LUFA/Drivers/USB/Core/USBTask.o ./LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.o ./LUFA/Drivers/USB/Class/Host/AudioClassHost.o ./LUFA/Drivers/USB/Class/Host/CDCClassHost.o ./LUFA/Drivers/USB/Class/Host/HIDClassHost.o ./LUFA/Drivers/USB/Class/Host/MIDIClassHost.o ./LUFA/Drivers/USB/Class/Host/MassStorageClassHost.o ./LUFA/Drivers/USB/Class/Host/PrinterClassHost.o ./LUFA/Drivers/USB/Class/Host/RNDISClassHost.o ./LUFA/Drivers/USB/Class/Host/StillImageClassHost.o ./LUFA/Drivers/USB/Class/Device/AudioClassDevice.o ./LUFA/Drivers/USB/Class/Device/CDCClassDevice.o ./LUFA/Drivers/USB/Class/Device/HIDClassDevice.o ./LUFA/Drivers/USB/Class/Device/MIDIClassDevice.o ./LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.o ./LUFA/Drivers/USB/Class/Device/PrinterClassDevice.o ./LUFA/Drivers/USB/Class/Device/RNDISClassDevice.o ./LUFA/Drivers/USB/Class/Common/HIDParser.o ./LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.o ./LUFA/Drivers/Peripheral/XMEGA/TWI_XMEGA.o ./LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.o ./LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.o ./LUFA/Drivers/Board/Temperature.o ./LUFA/Build/DMBS/Template/Template.o ./LUFA/Build/DMBS/DMBS/HID_EEPROM_Loader/HID_EEPROM_Loader.o ./Descriptors.o ./VirtualSerial.o
./LUFA/Build/DMBS/DMBS/HID_EEPROM_Loader/HID_EEPROM_Loader.o: In function main':
HID_EEPROM_Loader.c:(.text.startup.main+0x0): multiple definition ofmain'
./LUFA/Build/DMBS/Template/Template.o:Template.c:(.text.startup.main+0x0): first defined here
./VirtualSerial.o: In function main':
VirtualSerial.c:(.text.startup.main+0x0): multiple definition ofmain'
./LUFA/Build/DMBS/Template/Template.o:Template.c:(.text.startup.main+0x0): first defined here
./LUFA/Drivers/USB/Class/Device/AudioClassDevice.o: In function Audio_Device_ProcessControlRequest':
AudioClassDevice.c:(.text.Audio_Device_ProcessControlRequest+0xf8): undefined reference toCALLBACK_Audio_Device_GetSetEndpointProperty'
AudioClassDevice.c:(.text.Audio_Device_ProcessControlRequest+0x15a): undefined reference to CALLBACK_Audio_Device_GetSetEndpointProperty'
AudioClassDevice.c:(.text.Audio_Device_ProcessControlRequest+0x182): undefined reference toCALLBACK_Audio_Device_GetSetInterfaceProperty'
AudioClassDevice.c:(.text.Audio_Device_ProcessControlRequest+0x1e4): undefined reference to CALLBACK_Audio_Device_GetSetInterfaceProperty'
AudioClassDevice.c:(.text.Audio_Device_ProcessControlRequest+0x236): undefined reference toCALLBACK_Audio_Device_GetSetEndpointProperty'
AudioClassDevice.c:(.text.Audio_Device_ProcessControlRequest+0x284): undefined reference to CALLBACK_Audio_Device_GetSetInterfaceProperty'
./LUFA/Drivers/USB/Class/Device/HIDClassDevice.o: In functionHID_Device_ProcessControlRequest':
HIDClassDevice.c:(.text.HID_Device_ProcessControlRequest+0xd0): undefined reference to CALLBACK_HID_Device_CreateHIDReport'
HIDClassDevice.c:(.text.HID_Device_ProcessControlRequest+0x18e): undefined reference toCALLBACK_HID_Device_ProcessHIDReport'
./LUFA/Drivers/USB/Class/Device/HIDClassDevice.o: In function HID_Device_USBTask':
HIDClassDevice.c:(.text.HID_Device_USBTask+0xa2): undefined reference toCALLBACK_HID_Device_CreateHIDReport'
./LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.o: In function MS_Device_USBTask':
MassStorageClassDevice.c:(.text.MS_Device_USBTask+0xf4): undefined reference toCALLBACK_MS_Device_SCSICommandReceived'
./LUFA/Drivers/USB/Class/Common/HIDParser.o: In function USB_ProcessHIDReport':
HIDParser.c:(.text.USB_ProcessHIDReport+0x5bc): undefined reference toCALLBACK_HIDParser_FilterHIDReportItem'
./LUFA/Build/DMBS/DMBS/HID_EEPROM_Loader/HID_EEPROM_Loader.o: In function main':
HID_EEPROM_Loader.c:(.text.startup.main+0x4): undefined reference to_binary_InputEEData_bin_size'
HID_EEPROM_Loader.c:(.text.startup.main+0x6): undefined reference to _binary_InputEEData_bin_size'
HID_EEPROM_Loader.c:(.text.startup.main+0xe): undefined reference to_binary_InputEEData_bin_start'
HID_EEPROM_Loader.c:(.text.startup.main+0x10): undefined reference to `_binary_InputEEData_bin_start'
collect2.exe: error: ld returned 1 exit status
make: *** [Test1.elf] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
Solved it!
There were a lot of c-files, that were unnecessary, but eclipse wanted to compile them anyway. I excluded them and now it´s working.

What is the correct Java mapping of the shm_open function?

I'm trying to write some JNA code that accesses glibc, specifically functions defined in mmap.h.
I have tried to define it exactly as shown in man shm_open. The getuid() function call just before it works, but shm_open doesn't return.
I'm constrained to using JNA 4.4.0 and JNA Platform 3.4.0.
interface LibC extends Library {
LibC INSTANCE = Native.loadLibrary("c", LibC.class);
int shm_open(String name, int oFlag, int mode);
}
// ...
int fileDescriptor = LibC.INSTANCE.shm_open("/some_memory.123", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
// ...
I expect a file descriptor to be returned, but I get these exceptions:
When I load "libc.so.6": java.lang.UnsatisfiedLinkError: Error looking up function 'shm_open': /lib/x86_64-linux-gnu/libc.so.6: undefined symbol: shm_open
When I load "c": java.lang.UnsatisfiedLinkError: Error looking up function 'shm_open': /usr/lib/jvm/java-8-openjdk-amd64/bin/java: undefined symbol: shm_open
Well, I figured out the issue while writing the question.
While getuid() and friends are defined in libc, shm_open and friends are defined in librt. I really should have realized that because the manpage for shm_open explicitly states "Link with -lrt", indicating it residing in the "rt" lib.
In short: I need a new interface for LibRT alongside LibC, loaded with name rt.

(clang++) Symbol not found from libstdc++.6.0.9.dylib

I meet an error called "Symbol not found" on matlab. The error message is in below.
Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: blabla/lib/buildW.mexmaci64
Expected in: /usr/lib/libstdc++.6.0.9.dylib
There are quite bunch of questions like me, but I never found the solution of this problem. The former threads mentioned conflicts between the updated clang and the clang used.
Here are exmaples of questions on the similar question.
Need help finding Undefined Symbols
Handling "dyld: lazy symbol binding failed: Symbol not found" error when nm does not find symbol
https://github.com/Homebrew/homebrew-core/issues/4902
I currently installed Xcode 9.2.
And in matlab, I use MacOSX10.13.sdk like below.
>> edit ([matlabroot '/bin/maci64/mexopts/clang++_maci64.xml'])
...
...
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk" />
<cmdReturns name="find $$ -name MacOSX10.13.sdk" />
Also, I found that there are three files in "/usr/lib"
/usr/lib/libstdc++.6.0.9.dylib
/usr/lib/libstdc++.6.dylib
/usr/lib/libstdc++.dylib
Can anyone help me?
The symbol __ZNKSt5ctypeIcE13_M_widen_initEv (demangled std::ctype<char>::_M_widen_init() const) is defined in libstdc++.dylib but if you execute
nm /usr/lib/libstdc++.dylib | fgrep __ZNKSt5ctypeIcE13_M_widen_initEv
you will get
0000000000006a14 t __ZNKSt5ctypeIcE13_M_widen_initEv
as result. The t means that it's defined in the TEXT section but it's a local symbol which cannot referenced from outside the library.
Clang in Xcode uses
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/lib/libstdc++.tbd
for linking instead of /usr/lib/libstdc++.dylib. This is a human readable file which contains only the name of the public symbols in libstdc++.dylib. Since the symbol above is private it is not listed in the .tbd file.

Swift: Undefined Symbols: iTunesApplication

I'm trying to create Swift OS X app now, and found difficulty using ScriptingBridge.
I included proper iTunes.h file, and Xcode is not giving any error when I wrote "iTunesApplication" as type.
However, when I compile(run) the app, it gives me error :(
Does anybody know about this issue?
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_iTunesApplication", referenced from:
__TFC12LoveYouChloe11AppDelegate10showWindowfS0_FPSs9AnyObject_T_ in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And here is my code:
var iTunes: iTunesApplication = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") as iTunesApplication
iTunes.playpause()
The best way to solve this is to take the generated Objective-C Scripting Bridge header and convert it into a native Swift. I wrote a Python script (here) that can do that for you. You can see my answer here for a better explanation of what exactly is going on if you're interested.
Instead of
var iTunes: iTunesApplication = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes")
use
var iTunes: AnyObject = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes")
Sometimes the compiler gets confused when you are accessing two or more properties in a row(no idea why) so you may need to use a temporary variable. E.g.:
Instead of:
let songName: String = iTunes.playlists[0].songs[0].name
Try:
let song: AnyObject = iTunes.playlists[0].songs[0]
let songName = song.name
Or Alternatively the faster (this also works if you declare iTunes as an SBApplication) :
let songName: String = iTunes.valueAtIndex(0, inPropertyWithKey: "playlists").valueAtIndex(0, inPropertyWithKey: "songs").valueForKey("name")
EDIT:
You can also generate the .swift headers as specified here: https://github.com/tingraldi/SwiftScripting

compile option for rcpp and lib files in windows

Hi I am trying to work with the rcpp. For this I want some cpp code which loads a dll by use of a lib-file (which has the same name as ). the code which I let run is:
cppFunction(includes=c("#include "windef.h","#include \"C:/data/Rdata/IHUAPI.H\" "), 'int functietom(int a){long serverhandle;int lRet;lRet = ihuConnect ( "historian1",NULL,NULL, &serverhandle ); return 5;}', verbose
= TRUE)
I get the following error:
undefined reference to `ihuConnect#16' collect2: ld returned 1 exit
status Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
'C:/Users/user1663/AppData/Local/Temp/RtmpSW1Ki7/sourcecpp_1a04df63309/sourceCpp_26588.dll':
LoadLibrary failure:
the ihuConnect function is located in the ihuapi.lib and ihuape.dll files. In c++ in visual studio I add the lib file as added dependency and then I get rid of this error because I also sometimes get this error and then it was that I forgot to add the lib file in the compilation.
Thus My question is: how can I add this lib file as option in the compilation.
when I use dyn.load
("C:/data/Rdata/ihUAPI.dll")
and then check if it is loaded then he says yes
the problem is that getDLLRegisteredRoutines('ihUAPI', addNames = TRUE)
then it says:
data frame with 0 columns and 0 rows
so the dll seems not to contain the functions but it does when I use it from visual studio.
So please some help with lib-files and ddl-files
Tom Wambecq
You missed the Rcpp FAQ entry 2.9 'Can I use Rcpp with Visual Studio ?'.
And to kill all the suspense: No, you cannot.

Resources