Bugzilla – Bug 413
python bindings not portable to OS X
Last modified: 2008-11-25 07:48:26 EST
I'm getting the following error when trying to enable Python on OS X: [531/532] cxx_link: build/debug/bindings/python/ns3module_3.o build/debug/bindings/python/ns3module_helpers_3.o build/debug/bindings/python/ns3_module_bridge_3.o build/debug/bindings/python/ns3_module_common_3.o build/debug/bindings/python/ns3_module_contrib_3.o build/debug/bindings/python/ns3_module_core_3.o build/debug/bindings/python/ns3_module_csma_3.o build/debug/bindings/python/ns3_module_global_routing_3.o build/debug/bindings/python/ns3_module_helper_3.o build/debug/bindings/python/ns3_module_internet_stack_3.o build/debug/bindings/python/ns3_module_mobility_3.o build/debug/bindings/python/ns3_module_node_3.o build/debug/bindings/python/ns3_module_olsr_3.o build/debug/bindings/python/ns3_module_onoff_3.o build/debug/bindings/python/ns3_module_packet_sink_3.o build/debug/bindings/python/ns3_module_point_to_point_3.o build/debug/bindings/python/ns3_module_simulator_3.o build/debug/bindings/python/ns3_module_stats_3.o build/debug/bindings/python/ns3_module_udp_echo_3.o build/debug/bindings/python/ns3_module_wifi_3.o -> build/debug/bindings/python/ns3/_ns3.so /usr/bin/ld: Undefined symbols: _environ collect2: ld returned 1 exit status This seems to be a common problem for OS X, but am not sure how to best address it in our codebase: http://wiki.finkproject.org/index.php/Fink:Porting_Notes#The__environ_symbol
I don't get it. Neither the NS-3 library nor the NS-3 Python module use any kind of '_environ' symbol. Moreover I am no longer able to ssh into darwin-ppc like I used to, so I am not able to test this.
Created attachment 311 [details] darwin-ppc build fix This patch fixes build errors on the darwin-ppc regression host. It builds fine there and runs Python unit tests. Still no idea about this _environ issue reported here.
Comment on attachment 311 [details] darwin-ppc build fix I am waiting for approval from whoever owns the icmpv4 code to commit this.
(In reply to comment #2) > Created an attachment (id=311) [details] > darwin-ppc build fix > > This patch fixes build errors on the darwin-ppc regression host. It builds > fine there and runs Python unit tests. Still no idea about this _environ issue > reported here. > I really don't like this patch: the code should be fine without it. Would you mind show me the compiler error message together with compiler version ?
(In reply to comment #4) > (In reply to comment #2) > > Created an attachment (id=311) [details] [details] > > darwin-ppc build fix > > > > This patch fixes build errors on the darwin-ppc regression host. It builds > > fine there and runs Python unit tests. Still no idea about this _environ issue > > reported here. > > > > I really don't like this patch: the code should be fine without it. Would you > mind show me the compiler error message together with compiler version ? The bug happens because the python headers include /usr/include/sys/termios.h which defines the macro ECHO to 0x000008 This is really butt-ugly, especially since if you grep for ICMP_ECHO in /usr/include/*, you will find netinet/ip_icmp.h which defines it so, adding the ICMP prefix is not bullet-proof. I don't really know what to do: the C preprocessor is a killer.
(In reply to comment #5) > The bug happens because the python headers include /usr/include/sys/termios.h > which defines the macro ECHO to 0x000008 > > This is really butt-ugly, especially since if you grep for ICMP_ECHO in > /usr/include/*, you will find netinet/ip_icmp.h which defines it so, adding the > ICMP prefix is not bullet-proof. Similar approach was followed by e.g. SocketError. > > I don't really know what to do: the C preprocessor is a killer. If it were up to me I would still commit this patch as is. It may not be bullet proof, but it fixes our immediate problem. I don't like fixing potential/unlikely problems. Another approach would be to #ifdef ECHO #undef ECHO #endif, after including <Python.h> but before including ns-3 headers.
(In reply to comment #6) > Another approach would be to #ifdef ECHO #undef ECHO #endif, after including > <Python.h> but before including ns-3 headers. If that works, I would very much prefer this.
(In reply to comment #7) > (In reply to comment #6) > > > Another approach would be to #ifdef ECHO #undef ECHO #endif, after including > > <Python.h> but before including ns-3 headers. > > If that works, I would very much prefer this. > In that case, let's not argue about it. Committed. Only problem remaining is the _environ issue, which I cannot reproduce on darwin-ppc unfortunately.
(In reply to comment #8) > (In reply to comment #7) > > (In reply to comment #6) > > > > > Another approach would be to #ifdef ECHO #undef ECHO #endif, after including > > > <Python.h> but before including ns-3 headers. > > > > If that works, I would very much prefer this. > > > > In that case, let's not argue about it. Committed. > > Only problem remaining is the _environ issue, which I cannot reproduce on > darwin-ppc unfortunately. > I cannot reproduce the _environ issue anymore either, so please mark as fixed if it passes the overnight tests.