google-code-export / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Failed to import pymssql on FreeBSD - erroneously attempting to link with bundled Linux FreeTDS library #97

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. python setup.py install
2. import pymssql

>>> import pymssql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_mssql.pxd", line 10, in init pymssql (pymssql.c:9308)
ImportError: 
/usr/local/lib/python2.7/site-packages/pymssql-2.0.0b1_dev_20111019-py2.7-freebs
d-8.2-STABLE-amd64.egg/_mssql.so: Undefined symbol "stdout"

Environment

FreeBSD freebsd-8.2-pure 8.2-STABLE FreeBSD 8.2-STABLE amd64
Python 2.7.2 (default, Sep 25 2011, 23:02:46)

Original issue reported on code.google.com by eugene.r...@gmail.com on 26 Jul 2012 at 3:31

GoogleCodeExporter commented 9 years ago
This, I'm sure, has to do with how I am compiling the FreeTDS binaries.  
Unfortunately, C is really not my area of expertise and certainly not 
cross-platform C.  If you know how to fix this, please share.

Thanks.

Original comment by rsyr...@gmail.com on 26 Jul 2012 at 6:59

GoogleCodeExporter commented 9 years ago
I googled that "Undefined symbol "stdout"" message usually mean that some of 
binary was compiled for Linux, not for FreeBSD. For example, here: 
http://lists.freebsd.org/pipermail/freebsd-hackers/2005-December/014806.html
Unfortunately it's the only hint I have.
If I discover more I'll let you know.

Original comment by eugene.r...@gmail.com on 26 Jul 2012 at 7:40

GoogleCodeExporter commented 9 years ago
Looks like there is precompiled static libsybdb.a in pymssql package. How and 
where it was built?

Original comment by eugene.r...@gmail.com on 26 Jul 2012 at 7:48

GoogleCodeExporter commented 9 years ago
You can build it for yourself on FreeBSD, see the docs for FreeTDS:

http://www.freetds.org/userguide/

Original comment by rsyr...@gmail.com on 26 Jul 2012 at 8:52

GoogleCodeExporter commented 9 years ago
I've managed to make it work. Manually build FreeTDS in FreeBSD environment and 
replaced library and headers in package. Then 'python setup.py install' and it 
works.
FYI FreeTDS version that work is 0.91, not 0.82. pymssql won't compile with 
0.82 cause of some difference in sybdb.h

As suggestion, source pymssql package should probably include FreeTDS sources 
instead of pre-built binaries. Also there another possibility: not to include 
FreeTDS in source package at all but require path to installed FreeTDS on 
pymssql setup. That's what Perl DBD::Sybase module does.

Original comment by eugene.r...@gmail.com on 27 Jul 2012 at 7:45

GoogleCodeExporter commented 9 years ago
I meet this problem, too.

As what Eugene mentioned, I remove the "libsybdb.a" file in prebuild folder 
"freetds/nix_64/lib" and add "/usr/local/lib" into the "library_dirs" in 
setup.py. Then, it works.

Original comment by lemonla...@gmail.com on 24 Aug 2012 at 1:31

GoogleCodeExporter commented 9 years ago
I'm pretty sure that the fix for bug #106 
(http://code.google.com/p/pymssql/source/detail?r=88d15d12558625a4d7b8e2d518e24f
53c20223c9) will fix this issue too. Mac OS X is a FreeBSD-derivative and the 
problem in both bugs is the same -- that we were erroneously trying to link 
with a Linux binary on a non-Linux platform.

If you guys, could try again with FreeBSD on the hg tip and report back, that 
would be great. If there are still problems on FreeBSD, reopen this (if that's 
possible) or open a new issue.

Original comment by msabr...@gmail.com on 7 Jan 2013 at 3:42

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/pymssql/source/detail?r=88d15d12558625a4d7b8e2d518e24f5
3c20223c9 won't fix, because on FreeBSD9, sys.platform == "freebsd9".

Original comment by yin...@gmail.com on 28 May 2013 at 1:03

GoogleCodeExporter commented 9 years ago

Original comment by msabr...@gmail.com on 16 Jul 2013 at 5:39

GoogleCodeExporter commented 9 years ago
yingbo, good point! I wasn't thinking straight.

OK, I think this commit should fix it:

https://code.google.com/p/pymssql/source/detail?r=0a34be16c31c52de15f0a59c3210f9
4cf110d533

The above commit should make it only use the bundled freetds in 
freetds/nix_{32,64} when platform.system() == 'Linux'

Can someone with FreeBSD please verify?

Original comment by msabr...@gmail.com on 16 Jul 2013 at 5:41

GoogleCodeExporter commented 9 years ago

Original comment by msabr...@gmail.com on 7 Aug 2013 at 2:58

GoogleCodeExporter commented 9 years ago
I just tested this on FreeBSD 8.2. With no FreeTDS installed, `python setup.py 
build_ext -i` did not try to use the bundled FreeTDS. It errors out saying that 
it cannot find sqlfront.h. With the FreeTDS port installed, `python setup.py 
build_ext -i` build pymssql successfully.

As an additional aid for FreeBSD users, I made the following commit:

https://code.google.com/p/pymssql/source/detail?r=b259f548e37442a4ca88711e9b6493
449bd12a3f

which will output some useful info about installing FreeTDS for FreeBSD users. 
For example, here's the output when trying to install pymssql when there is no 
FreeTDS installed:

[marca@ ~/dev/pymssql]$ python setup.py build_ext -i setup.py: platform.system() => 'FreeBSD' setup.py: Detected FreeBSD. For FreeBSD, you can install FreeTDS with FreeBSD Ports or by downloading and compiling it yourself.

If you use the Port, make sure to specify the option MSDBLIB.

If you build FreeTDS yourself, make sure to call ./configure with
--enable-msdblib.

setup.py: Not using bundled FreeTDS setup.py: include_dirs = ['/usr/local/include'] setup.py: library_dirs = ['/usr/local/lib'] running build_ext cythoning _mssql.pyx to _mssql.c building '_mssql' extension creating build creating build/temp.freebsd-8.2-RELEASE-amd64-2.7 cc -fno-strict-aliasing -O2 -pipe -Dwchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fno-strict-aliasing -DNDEBUG -O2 -pipe -Dwchar_t=wchar_t -DTHREAD_STACK_SIZE=0x20000 -fno-strict-aliasing -fPIC -I/usr/local/include -I/usr/local/include/python2.7 -c _mssql.c -o build/temp.freebsd-8.2-RELEASE-amd64-2.7/_mssql.o -DMSDBLIB In file included from _mssql.c:314: freetds.h:1:22: error: sqlfront.h: No such file or directory ...


Marking this verified.

Original comment by msabr...@gmail.com on 30 Aug 2013 at 5:27