473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

gcc compile / link questions

I compile and link Python extension modules using the script

gcc -fPIC -g -I/usr/local/include/python2.3 \
-Wall -Wstrict-prototypes -c mymodule.c
g++ -shared mymodule.o -L/usr/local/lib -o mymodule.so

It works for me but it isn't pretty. Is there a better way to write it?

Gcc finds all the libraries that need to be linked in. For example,
"/usr/local/lib/python2.3/site-packages/numarray/libnumarray.so". How
does gcc do this?

I created a .so file "utilities.so" that contains some C functions that
are called in mymodule.c but are not visible from Python. Both
"utilities.c" and "mymodule.c" use numarray. What changes do I make in
the script above? Must I use the nasty "libnumarray_UNIQUE_SYMBOL" trick?

What is a script for creating "utilities.a" using gcc? How do I change
the script above to include "utilities.a"?

Jul 18 '05 #1
1 2740
"Edward C. Jones" <ed******@erols.com> writes:
I compile and link Python extension modules using the script

gcc -fPIC -g -I/usr/local/include/python2.3 \
-Wall -Wstrict-prototypes -c mymodule.c
g++ -shared mymodule.o -L/usr/local/lib -o mymodule.so

It works for me but it isn't pretty. Is there a better way to write it?
Yes, you should write a setup.py using distutils.
Gcc finds all the libraries that need to be linked in. For example,
"/usr/local/lib/python2.3/site-packages/numarray/libnumarray.so". How
does gcc do this?
I doubt this statement. gcc does not find things in
/usr/local/lib/python2.3. Why do you think it does?
I created a .so file "utilities.so" that contains some C functions
that are called in mymodule.c but are not visible from Python. Both
"utilities.c" and "mymodule.c" use numarray. What changes do I make in
the script above? Must I use the nasty "libnumarray_UNIQUE_SYMBOL"
trick?


You cannot access symbols from different extension modules; each
module has its own, separate, space of symbols. If you want to invoke
functions in a different module, you must do so through the Python
API.

Some extension modules provide a CObject containing the API; if
numarray offers such a thing, you should use it.

Regards,
Martin
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: edward hage | last post by:
Hello, I have a Linux machine and I use Netscape 7.1 which I upgraded from Mozilla. I downloaded j2sdj-1.4.2_02 and I have installed the plugins as followes: in .mozilla/plugins- directory a...
3
by: Mike van der Hulst | last post by:
Hello, I'm not farmiliar with C++ programming. I want to try a software, but I only have the sourcefiles, not the executable for Win XP It's a EIB <--> XML driver application I'm looking...
9
by: Jaime | last post by:
I am using Microsoft Visual C++ and i have some projects configuration. (Configuration A, Configuration B, ..., Configuration N) I need to execute some system operation call such as copy, delete,...
10
by: Martin Jørgensen | last post by:
Hi, I got this piece of code, but I won't compile: #include <iostream> using namespace std; //////////////////////////////////////////////////////////////// struct link ...
1
by: å¼ æ²ˆé¹ | last post by:
How to compile the HelloWorld of boost.asio? Maybe this is a stupid problem , but I really don't konw how to find the right way. My compile environment is WinXP, Msys , MinGw , G++ 3.4.2,...
30
by: David T. Ashley | last post by:
I have a large project on a Linux box that may eventually have several hundred 'C' source files, which need to be compiled and linked into several executables. Not all of the executables will...
1
by: Loic Mahe | last post by:
Hello, I would like to compile GLib as a static library on Windows XP with MinGW if possible. I downloaded GLib and needed librairies, but only the .dll files are included in the zip file. ...
0
by: dot | last post by:
I spent a few headache filled days trying to use GMP on windows (XP pro) I finally got it to work and since I found little help on the Web I thought someone might find what i did useful. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.