CGAL linker error - Symbol not found: ___gmpq_clear - swig

I'm trying to incorporate CGAL into an existing simulation project, but am having some linker trouble. The python simulation keiro.py uses a file called physics.cpp in a swig wrapper for speeding up common operations...I managed to get my physics.cpp file to compile, but running the Python simulation errors out with the following message:
Traceback (most recent call last):
File "keiro.py", line 2, in
from world import World, View
File "/Users/marcstrauss/Desktop/keiro/world.py", line 9, in
from fast.physics import Vec2d, Particle, World as PhysicsWorld
File "/Users/marcstrauss/Desktop/keiro/fast/physics.py", line 7, in
import _physics
ImportError: dlopen(/Users/marcstrauss/Desktop/keiro/fast/physics.so, 2): Symbol not >found: __gmpq_clear
Referenced from: /Users/marcstrauss/Desktop/keiro/fast/_physics.so
Expected in: flat namespace
in /Users/marcstrauss/Desktop/keiro/fast/_physics.so
I figure that error with the ___gmpq_clear symbol not being recognized in the object file means that I'm not linking to CGAL properly. Here is my makefile:
all: physics.py _physics.so graphutils.py _graphutils.so
_physics.so: setup_physics.py physics_wrap.cxx physics.cpp
python setup_physics.py build_ext --inplace -I/opt/local/include/
_graphutils.so: setup_graphutils.py graphutils_wrap.cxx graphutils.cpp
python setup_graphutils.py build_ext --inplace -I/opt/local/include/
physics.py physics_wrap.cxx: physics.i physics.h
swig -python -c++ physics.i
graphutils.py graphutils_wrap.cxx: graphutils.i graphutils.h
swig -python -c++ graphutils.i -I/opt/local/include/
clean:
rm -f physics.py
rm -f graphutils.py
rm -f *.cxx
rm -f *~ *.pyc *.pyo
rm -f *.so
rm -rf build
Does anyone have any ideas for me as to how to fix this? Thanks!

On my computer the __gmpq_clear symbol is located in the libgmp library:
nm libgmp.a | grep gmpq_clear
00000000 T __gmpq_clear
Try adding -lgmp to your linking command.

Related

Error linking .o file to .wasm with wasm-ld

I've been trying to convert a cpp file to wasm without emscripten recently and I've been running with some errors, for example, when I run these commands:
clang++ --target=wasm32 -nostdlib -O3 -o public/main.o -c src/*.cpp
wasm-ld --no-entry --export-all --lto-O3 --allow-undefined --import-memory public/main.o -o public/main.wasm
it gives me this error:
wasm-ld: error: unknown file type public/main.o
Here are the versions of clang and lld that I currently have:
clang version 12.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/jp4r5v8pla63qam5w34jvfyfmq8p74am-clang-12.0.1/bin
LLD 12.0.1
Also, I'm running the code on replit
Thank you
Ok, with this commands it works :D
clang++ --target=wasm32 -emit-llvm -c -S -o public/files/main.ll src/main.cpp
llc -march=wasm32 -filetype=obj -o public/files/main.o public/files/main.ll
wasm-ld --no-entry --export-all -o public/main.wasm public/files/main.o
The only thing is that you need to create some new files (main.ll and main.o) but it doesn't matter.
The place where I obtained the solution is here: https://surma.dev/things/c-to-webassembly/index.html
It was really useful

cant install pygame in pycharm

First of all, I'm new to programming. So,forgive me for my mistakes. I've installed pygame in python IDLE. But when I try to install it in pycharm, this happens:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>pip install pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"?[Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ARMAN\AppData\Local\Temp\pip-install-5f1r3j6w\pygame\
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>py -m pip install -U pygame --user
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
Complete output from command python setup.py egg_info:
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x86"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\ARMAN\AppData\Local\Temp\pip-install-nykuwxyw\pygame\buildconfig\downloa
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\ARMAN\AppData\Local\T
(venv) C:\Users\ARMAN\PycharmProjects\GAMES>
I get an error. I've updated everything. Found a similar problem here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000435070-Command-python-setup-py-egg-info-failed-with-error-code-1-whatever-package-I-try-to-install-.
But I can't understand the solution. So, please kindly help me.
This isn't my answer, but an answer from here:
Pygame docs recommends that you use Python version 3.6.1 or greater,
so I would suggest you to use the most recent non-beta version. Also,
some pygame wheels are not available to this version yet.
After the python installation make sure its added to your PATH
variable and try to install Pygame using this command given that you
are on windows:
py -m pip install -U pygame --user
If you get a PermissionError then
run the command prompt as administrator.
I hope this helps.

gcc failed with install Python MySQL libraries on Cygwin

I want to install either oursql or MySQLdb on a Cygwin box. (Pywikibot can work with either.)
Unfortunately both easy_install as well as pip fail at installing both.
easy_install-2.7 oursql
Searching for oursql
Reading https://pypi.python.org/simple/oursql/
Reading http://launchpad.net/oursql
Best match: oursql 0.9.3.1
Downloading https://pypi.python.org/packages/source/o/oursql/oursql-0.9.3.1.zip#md5=ad599ea2d95fc695df7195e9801b45c2
Processing oursql-0.9.3.1.zip
Writing /tmp/easy_install-kA8kUA/oursql-0.9.3.1/setup.cfg
Running oursql-0.9.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-kA8kUA/oursql-0.9.3.1/egg-dist-tmp-Jh5tJ1
cython not found, using previously-cython'd .c file.
mysql_config --cflags
In file included from oursqlx/oursql.c:235:0:
oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
#include "mysql.h"
^
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
easy_install-2.7 mysql-python
Searching for mysql-python
Reading https://pypi.python.org/simple/mysql-python/
Best match: MySQL-python 1.2.5
Downloading https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c
Processing MySQL-python-1.2.5.zip
Writing /tmp/easy_install-JwMXUV/MySQL-python-1.2.5/setup.cfg
Running MySQL-python-1.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-JwMXUV/MySQL-python-1.2.5/egg-dist-tmp-jjPy0m
error: Setup script exited with error: command 'gcc' terminated by signal 11
I haven't done much gcc fixing in the past decade so I'm not sure how to handle this.
Try this, this may help you: Windows GCC (MinGW) binaries for Python developers

Can't compile Cython function with multiple input arguments

I am trying to get Cython running and I think I'm almost there but have hit a snag that I do not understand. I can compile functions with a single argument, but not with multiple. I have this issue with python 3.3, but not 2.7.
I successfully compiled and ran "hello world" and fibonacci examples but when I try to compile anything with two or more input arguments I get an error when compiling.
To boil it down to a very simple case. This compiles, imports to python, and runs.
def cycheckadd(c):
b = 1
d = b + c
return d
This does not.
def cycheckadd(b,c):
d = b + c
return d
And returns the following error when building.
C:\Users\Chris\PycharmProjects\CythonTest>python setup.py build_ext --inplace
Compiling cycheck.pyx because it changed.
Cythonizing cycheck.pyx
running build_ext
building 'cycheck' extension
creating build
creating build\temp.win32-3.3
creating build\temp.win32-3.3\Release
c:\mingw\bin\gcc.exe -mdll -O -Wall -IC:\WinPython-32bit-3.3.5.9\python-3.3.5\include -IC:\WinPython-32bit-3.3.5.9\python-3.3.5\include -c cycheck.c -o build\temp.win32-3.3\Release\
cycheck.o
writing build\temp.win32-3.3\Release\cycheck.def
creating build\lib.win32-3.3
c:\mingw\bin\gcc.exe -shared -s build\temp.win32-3.3\Release\cycheck.o build\temp.win32-3.3\Release\cycheck.def -LC:\WinPython-32bit-3.3.5.9\python-3.3.5\libs -LC:\WinPython-32bit-3
.3.5.9\python-3.3.5\PCbuild -lpython33 -lmsvcr100 -o build\lib.win32-3.3\cycheck.pyd
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmsvcrt.a(dupvs00137.o):(.idata$5+0x0): multiple definition of `_imp___assert'
C:\WinPython-32bit-3.3.5.9\python-3.3.5\libs/libmsvcr100.a(dqcgs00457.o):(.idata$5+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Compiled using the setup.py file below.
from setuptools import setup
from Cython.Build import cythonize
setup(
name = 'cython math check',
ext_modules = cythonize("cycheck.pyx"),
)
This result was generated using python 3.3 and cython 0.22. I do not have this problem when I use 2.7.
The compiler is MinGW. I have been using 32bit versions of Python on Windows 10-64bit. I have added the following config file to the python directory.
C:\WinPython-32bit-3.3.5.9\python-3.3.5\Lib\distutils\distutils.cfg
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
Any help would be greatly appreciated!
Thanks,
Chris

pycuda -- error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1

i installed sabayon linux and i tried to install pycuda but i am receiving the following error when i try
su -c "make install"
In file included from src/cpp/cuda.cpp:1:0: src/cpp/cuda.hpp:12:18:
fatal error: cuda.h: No such file or directory compilation terminated.
error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1
I must mention that i can compile with cuda.
The same happens and when i try with
sudo -E sh -c "make install"
My .bashrc is :
# Put your fun stuff here.
export PATH=~/bin:$PATH
export PATH=$PATH:$HOME/Matlab_2010b/bin
export PATH=/opt/cuda/bin:$PATH
export LD_LIBRARY_PATH=/opt/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_ROOT=/opt/cuda/bin
(When i do echo $PATH as user it shows me : /opt/cuda/bin but when i try it as root it doesn't show anything and i had to do export PATH...again in order to show.)
You have CUDA installed in a non-standard path and the PyCUDA installer doesn't know how to find the toolkit headers it needs to compile. As per the installation instructions, you need to do something like this:
python configure.py --cuda-root=/opt/cuda
then
su -c "make install"
this will ensure that the compilation can find the necessary driver API headers to build the support libraries and hardcode all the right paths into the PyCUDA python libraries so that everything works correctly.