Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; '#include': 0.07; 'args)': 0.07; 'exception.': 0.07; 'null,': 0.07; 'python': 0.09; '-1,': 0.09; 'bool': 0.09; 'raised.': 0.09; 'referenced': 0.09; 'subject:module': 0.09; 'subject:error': 0.11; 'extension': 0.13; 'static': 0.13; 'library': 0.15; "skip:' 30": 0.15; '3.3.': 0.16; 'dword': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'lowercase': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; "module's": 0.16; 'null}': 0.16; 'pymethoddef': 0.16; 'pyobject*': 0.16; 'skip:/ 70': 0.16; 'underscores,': 0.16; 'unresolved': 0.16; '{null,': 0.16; 'wrote:': 0.17; 'module': 0.19; 'skip:p 30': 0.20; 'trying': 0.21; 'builder': 0.22; 'converted': 0.22; 'file:': 0.22; 'null;': 0.22; 'struct': 0.22; 'skip:_ 20': 0.22; 'this:': 0.23; 'external': 0.24; 'paul': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'wonder': 0.27; 'c++': 0.27; 'received:192.168.1.3': 0.29; 'source': 0.29; 'function': 0.30; 'error': 0.30; "skip:' 20": 0.32; 'says': 0.33; 'null': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'returning': 0.35; 'should': 0.36; 'skip:p 20': 0.36; 'subject: (': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'export': 0.62; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=OqzNOlDt c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=b2nRVtXOy8EA:10 a=eVYuEFWP0y4A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=dt5Q43Ci3N4A:10 a=Fp-HRxUELfgVIPH2q8QA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Mon, 22 Oct 2012 19:03:05 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Compiling extension module (linker error) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 89 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350928995 news.xs4all.nl 6967 [2001:888:2000:d::a6]:36920 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31899 On 2012-10-22 11:55, Paul Volkov wrote: > I am trying to compile an extension module with C++ Builder 6 for Python 3.3. > I converted python33.lib using coff2omf.exe and added this library > into my project. > I wonder why I get this error message while building: > > [Linker Error] Unresolved external '_PyModule_Create2TraceRefs' > referenced from 'D:\WORK\FROMAGE\OUT\ROSE_UNIT.OBJ' > > My source file: > > //--------------------------------------------------------------------------- > > #include > #include > #pragma argsused > It's a Python module with its own initialiser, so you don't need this: > BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved) > { > return 1; > } > You don't need to export this function because it's listed in the module's function table: > static PyObject* __declspec(dllexport) testik(PyObject* self, PyObject* args) > { Returning NULL says that an exception was raised. You should set the exception. > return NULL; > } > > static PyMethodDef FundRoseMethods[] = { > {"testik", testik, METH_VARARGS, "perform a test"}, > {NULL, NULL, 0, NULL} > }; > > static struct PyModuleDef FundRoseModule = { > PyModuleDef_HEAD_INIT, > "FundRose", > NULL, > -1, > FundRoseMethods > }; > > PyMODINIT_FUNC > PyInit_FundRose(void) > { > return PyModule_Create(&FundRoseModule); > } > > //--------------------------------------------------------------------------- > By the way, the recommendation is for module names to be lowercase with underscores, so "fund_rose" instead of "FundRose". Try this code: #include #include #pragma argsused static PyObject* testik(PyObject* self, PyObject* args) { PyErr_SetString(PyExc_RuntimeError, "testik exception"); return NULL; } static PyMethodDef FundRoseMethods[] = { {"testik", testik, METH_VARARGS, "perform a test"}, {NULL, NULL, 0, NULL} }; static struct PyModuleDef FundRoseModule = { PyModuleDef_HEAD_INIT, "FundRose", NULL, -1, FundRoseMethods }; PyMODINIT_FUNC PyInit_FundRose(void) { return PyModule_Create(&FundRoseModule); }