I was able to successfully build cython on Ubuntu 14.04 from source as explained in this SE question/answer Compiling cython From source with icc and I downloaded the source code from here - Cython source code download.
The command to compile cython is
CC=icc LINKCC=icc python3.4 setup.py build
I am enclosing the build log. It is STILL using gcc for linking. Here is a sample of build log.
It appears CC=icc LINKCC=icc does NOT seem to change the linker to icc. It is still using x86_64-linux-gnu-gcc. When I set the environmental variable LDFLAGS = -lirc the environmental variable is being passed to gcc and not to icc.
Also when I put print statements in BuildExecutable.py they are not getting called.
icc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c /home/aswin/libPython/Cython-0.24/Cython/Plex/Scanners.c -o build/temp.linux-x86_64-3.4/home/aswin/libPython/Cython-0.24/Cython/Plex/Scanners.o
icc: command line warning #10006: ignoring unknown option '-fwrapv'
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/Cython
creating build/lib.linux-x86_64-3.4/Cython/Plex
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -lirc -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/home/aswin/libPython/Cython-0.24/Cython/Plex/Scanners.o -o build/lib.linux-x86_64-3.4/Cython/Plex/Scanners.cpython-34m.so
How do I fix it ?
You need to override the linker
by setting export LDSHARED="icc -shared". That generates the icc linker. Here is an example of the build log by typing
CC=icc python3.4 setup.py build_ext
Alternatively you can also do the same by typing
LDSHARED="icc -shared" CC=icc python3.4 setup.py build_ex
icc -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c /home/a/libPython/Cython-0.24/Cython/Plex/Scanners.c -o build/temp.linux-x86_64-3.4/home/a/libPython/Cython-0.24/Cython/Plex/Scanners.o
icc: command line warning #10006: ignoring unknown option '-fwrapv'
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/Cython
creating build/lib.linux-x86_64-3.4/Cython/Plex
icc -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/home/a/libPython/Cython-0.24/Cython/Plex/Scanners.o -o build/lib.linux-x86_64-3.4/Cython/Plex/Scanners.cpython-34m.so
cythoning /home/a/libPython/Cython-0.24/Cython/Plex/Actions.py to /home/a/libPython/Cython-0.24/Cython/Plex/Actions.c
You could try to add -static-intel to link options so that all Intel specific functions will be static-linked.
Related
I am unable to build rgdal (see output in code chunk below) on my AWS server. I understand from the discussion here, and here that this has something to do with missing libraries for geos and gdal, but none of the solutions suggested appears to work. If I run sudo yum install libgdal1 libgdal1-dev libgeos libgeos-dev I get the following output:
Loaded plugins: priorities, update-motd, upgrade-helper amzn-main
| 2.1 kB 00:00:00 amzn-updates
| 2.5 kB 00:00:00 1045 packages excluded due to repository
priority protections No package libgdal1 available. No package
libgdal1-dev available. Package geos-3.4.2-1.4.amzn1.x86_64 already
installed and latest version No package libgeos-dev available. Nothing
to do
I have already enabled EPEL, but it does not solve the problem.
Unfortunately I'm not very experienced with Linux, and have no idea how to move forward...
R output after attempting to install rgdal:
> install.packages("rgdal", type="source")
Installing package into ‘/home/andrea/R/x86_64-redhat-linux-gnu-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.3-2.tar.gz'
Content type 'application/x-gzip' length 1667049 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: CC: gcc -m64 -std=gnu99
configure: CXX: g++ -m64
configure: rgdal: 1.3-2
checking for /usr/bin/svnversion... no
configure: svn revision: 755
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -m64 accepts -g... yes
checking whether g++ -m64 supports C++11 features by default... no
checking whether g++ -m64 supports C++11 features with -std=gnu++11... yes
configure: C++11 support available
checking for gdal-config... /usr/local/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.0.0
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/local/share/gdal/pcs.csv readable... yes
checking proj_api.h presence and usability... yes
./configure: line 3395: test: =: unary operator expected
checking PROJ version >= 4.8.0... yes
checking projects.h presence and usability... yes
/tmp/ccV0TCuc.o: In function `main':
/tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/proj_conf_test2.c:14: undefined reference to `pj_get_default_ctx'
/tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/proj_conf_test2.c:20: undefined reference to `pj_ctx_fclose'
collect2: error: ld returned 1 exit status
./configure: line 3511: ./proj_conf_test2: No such file or directory
checking PROJ.4: epsg found and readable... yes
/tmp/cczdLgSd.o: In function `main':
/tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/proj_conf_test3.c:14: undefined reference to `pj_get_default_ctx'
/tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/proj_conf_test3.c:20: undefined reference to `pj_ctx_fclose'
collect2: error: ld returned 1 exit status
./configure: line 3570: ./proj_conf_test3: No such file or directory
checking PROJ.4: conus found and readable... yes
configure: Package CPP flags: -I/usr/local/include
configure: Package LIBS: -L/usr/local/lib -lgdal -lproj
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c OGR_write.cpp -o OGR_write.o
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c gdal-bindings.cpp -o gdal-bindings.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c init.c -o init.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c inverser.c -o inverser.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c local_stubs.c -o local_stubs.o
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ogr_geom.cpp -o ogr_geom.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ogr_polygons.c -o ogr_polygons.o
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ogr_proj.cpp -o ogr_proj.o
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ogrdrivers.cpp -o ogrdrivers.o
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c ogrsource.cpp -o ogrsource.o
g++ -m64 -std=gnu++11 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/home/andrea/R/x86_64-redhat-linux-gnu-library/sp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c projectit.cpp -o projectit.o
g++ -m64 -std=gnu++11 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o rgdal.so OGR_write.o gdal-bindings.o init.o inverser.o local_stubs.o ogr_geom.o ogr_polygons.o ogr_proj.o ogrdrivers.o ogrsource.o projectit.o -L/usr/local/lib -lgdal -lproj -L/usr/lib64/R/lib -lR
installing to /home/andrea/R/x86_64-redhat-linux-gnu-library/rgdal/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
converting help for package ‘rgdal’
finding HTML links ... done
CRS-class html
GDALDataset-class html
GDALDriver-class html
GDALMajorObject-class html
GDALRasterBand-class html
GDALReadOnlyDataset-class html
GDALReadOnlyDataset-methods html
GDALTransientDataset-class html
GridsDatums html
RGB2PCT html
SGDF2PCT html
SpatialGDAL-class html
closeDataset-methods html
displayDataset html
llgrid html
Rd warning: /tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/man/llgrid.Rd:11: missing file link ‘Spatial’
Rd warning: /tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/man/llgrid.Rd:16: missing file link ‘gridat’
Rd warning: /tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/man/llgrid.Rd:17: missing file link ‘gridat’
make_EPSG html
nor2k html
projInfo html
project html
readGDAL html
Rd warning: /tmp/Rtmp52ge38/R.INSTALL4e4e42b08a4a/rgdal/man/readGDAL.Rd:136: missing file link ‘flipVertical’
readOGR html
showWKT html
spTransform-methods html
wrappers html
writeOGR html
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/andrea/R/x86_64-redhat-linux-gnu-library/rgdal/libs/rgdal.so':
libgdal.so.20: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/andrea/R/x86_64-redhat-linux-gnu-library/rgdal’
Warning in install.packages :
installation of package ‘rgdal’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpnAqQL2/downloaded_packages’
The issue is that, while GDAL is correctly built, rgdal cannot find its libraries. This is because the AWS ec2 AMI does not include /usr/local/lib in the default search path for libraries. The solution is provided in an answer to this question.
In brief:
edit /etc/ld.so.conf using sudo vi /etc/ld.so.conf to make it contain: include /etc/ld.so.conf.d/*.conf.
Edit / create a file /etc/ld.so.conf.d/libc.conf so that it contains: /usr/local/lib
Run sudo ldconfig to save changes
This makes the libraries searchable when building rgdal.
Upgrade gcc version to 5.x.x, and then run the followings (depending on the gcc version, you may have a different file of libstdc++.so.6.0.25):
cp /usr/local/lib64/libstdc++.so.6.0.25 /lib64
cd /lib64
rm -rf libstdc++.so.6
ln -s libstdc++.so.6.0.25 libstdc++.so.6
I have installed (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5) already and jave also installed yum install gcc-gfortran . (Package gcc-gfortran-4.4.7-18.el6.x86_64)
But I'm getting error like :
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1
Please help me in installing -lgfortran. It seems like I need to install "Fortran -dev package providing the Fortran library". I do not know how to do that in RedHat/CentOS. Please help. I'm facing hard time in doing this.
I have tried installing libgfortran using:
yum install libgfortran
But it says:
Package libgfortran-4.4.7-18.el6.x86_64 already installed and latest version
Nothing to do
(Running in an interactive session, skipping clean step.)
More Info:
I tried installing package quadprog for R and below are the logs:
install.packages('https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz',dependencies = TRUE,repos = NULL,type ="source")
Installing package into '/usr/lib64/R/library'
(as 'lib' is unspecified)
trying URL 'https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz'
Content type 'application/x-gzip' length 33651 bytes (32 KB)
==================================================
downloaded 32 KB
* installing *source* package 'quadprog' ...
** package 'quadprog' successfully unpacked and MD5 sums checked
** libs
gfortran -m64 -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -c aind.f -o aind.o
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC -c init.c -o init.o
gfortran -m64 -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -ffloat-store -c -o solve.QP.compact.o solve.QP.compact.f
solve.QP.compact.f:254.3:
72 if (nvl .EQ. 0) then
1
Warning: Label 72 at (1) defined but not used
solve.QP.compact.f:302.2:
7 t1inf = .FALSE.
1
Warning: Label 7 at (1) defined but not used
solve.QP.compact.f: In function 'qpgen1':
solve.QP.compact.f:94: warning: 'it1' may be used uninitialized in this function
solve.QP.compact.f:98: warning: 't1' may be used uninitialized in this function
gfortran -m64 -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -ffloat-store -c -o solve.QP.o solve.QP.f
solve.QP.f:245.3:
72 if (nvl .EQ. 0) then
1
Warning: Label 72 at (1) defined but not used
solve.QP.f:293.2:
7 t1inf = .FALSE.
1
Warning: Label 7 at (1) defined but not used
solve.QP.f: In function 'qpgen2':
solve.QP.f:85: warning: 'it1' may be used uninitialized in this function
solve.QP.f:89: warning: 't1' may be used uninitialized in this function
gfortran -m64 -fvisibility=hidden -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/lib64/gfortran/modules -c util.f -o util.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -o quadprog.so aind.o init.o solve.QP.compact.o solve.QP.o util.o -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lgfortran -lm -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1
ERROR: compilation failed for package 'quadprog'
* removing '/usr/lib64/R/library/quadprog'
Warning message:
In install.packages("https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz", :
installation of package '/tmp/Rtmpry5XTG/downloaded_packages/quadprog_1.5-5.tar.gz' had non-zero exit status
Edits :
bash-4.1# rpm -ql libgfortran
/usr/lib64/libgfortran.so.3
/usr/lib64/libgfortran.so.3.0.0
You showed us this:
# type -a gcc
gcc is /opt/centos/devtoolset-1.1/root/usr/bin/gcc
gcc is /usr/bin/gcc'
It means that you have installed Red Hat Developer Toolset and enabled it for this shell, using scl enable or a similar command. Do you still need it? If not, I suggest to disable it.
If you need DTS, you will have to install the Fortran compiler from DTS 1.1, using:
yum install devtoolset-1.1-gcc-gfortran
(Or download it directly from here, which seems to be the repository from where you got your DTS compiler.)
This will install the Fortran compiler which is compatible with the gcc compiler you have configured. Without that, the system Fortran compiler and the DTS gcc are used together, which does not work because the DTS gcc command (used for linking in the build process you quoted) is not able to locate the libgfortran.so library from the system Fortran compiler.
Alternatively, you can bring the two compilers into sync by deinstalling the DTS compiler:
yum install devtoolset-1.1-gcc-gfortran
The following compile line was looking for libgfortran at /usr/lib64/R/lib but the library is not there. Hence, the linker error.
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -o quadprog.so aind.o init.o solve.QP.compact.o solve.QP.o util.o -L/usr/lib64/R/lib -lRblas -lgfortran -lm -lgfortran -lm -L/usr/lib64/R/lib -lR
As we could not locate and modify the makefile. We created a symbolic link /usr/lib64/R/lib/libgfortran.so to /usr/lib64/libgfortran.so.3 and rerun the installation steps and it resolves the linker error.
This is a work around that we follow which resolves the issue
So, I developed a python performance test to run some tests on an HSM. I am following directions to download PyKCS11, an important module I need on the remote machine. I have latest version of swig installed, and I'm trying to run a make build on the PyKCS11 folder I have downloaded in my directory on the machine. I'm getting an ungodly amount of errors when running the make build. An suggestions on what is happening with these errors?
make build
python setup.py build
running build
running build_py
running build_ext
building 'PyKCS11._LowLevel' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fe xceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU _SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexce ptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SO URCE -fPIC -fwrapv -fPIC -Isrc -I/usr/local/include -I/usr/include/python2.6 -c src/ck_attribute_smart.cpp -o build/temp.linux-x86_64-2.6/src/ck_attribute_smart .o
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fe xceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU _SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexce ptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SO URCE -fPIC -fwrapv -fPIC -Isrc -I/usr/local/include -I/usr/include/python2.6 -c src/pkcs11lib.cpp -o build/temp.linux-x86_64-2.6/src/pkcs11lib.o
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fe xceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU _SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexce ptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SO URCE -fPIC -fwrapv -fPIC -Isrc -I/usr/local/include -I/usr/include/python2.6 -c src/pykcs11string.cpp -o build/temp.linux-x86_64-2.6/src/pykcs11string.o
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fe xceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU _SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexce ptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SO URCE -fPIC -fwrapv -fPIC -Isrc -I/usr/local/include -I/usr/include/python2.6 -c src/utility.cpp -o build/temp.linux-x86_64-2.6/src/utility.o
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fe xceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU _SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexce ptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SO URCE -fPIC -fwrapv -fPIC -Isrc -I/usr/local/include -I/usr/include/python2.6 -c src/pykcs11_wrap.cpp -o build/temp.linux-x86_64-2.6/src/pykcs11_wrap.o
src/pykcs11_wrap.cpp:173:21: error: Python.h: No such file or directory
src/pykcs11_wrap.cpp:3050:4: error: #error "This python version requires swig to be run with the '-classic' option"
src/pykcs11_wrap.cpp:803: error: ‘PyObject’ was not declared in this scope
src/pykcs11_wrap.cpp:803: error: ‘str’ was not declared in this scope
src/pykcs11_wrap.cpp:804: error: expected ‘,’ or ‘;’ before ‘{’ token
src/pykcs11_wrap.cpp:827: error: expected initializer before ‘*’ token
src/pykcs11_wrap.cpp:853: error: expected initializer before ‘*’ token
src/pykcs11_wrap.cpp:903: error: expected initializer before ‘*’ token
src/pykcs11_wrap.cpp:918: error: ‘inquiry’ does not name a type
src/pykcs11_wrap.cpp:919: error: ‘intargfunc’ does not name a type
src/pykcs11_wrap.cpp:920: error: ‘intintargfunc’ does not name a type
src/pykcs11_wrap.cpp:921: error: ‘intobjargproc’ does not name a type
src/pykcs11_wrap.cpp:922: error: ‘intintobjargproc’ does not name a type
src/pykcs11_wrap.cpp:923: error: ‘getreadbufferproc’ does not name a type
src/pykcs11_wrap.cpp:924: error: ‘getwritebufferproc’ does not name a type
src/pykcs11_wrap.cpp:925: error: ‘getsegcountproc’ does not name a type
src/pykcs11_wrap.cpp:926: error: ‘getcharbufferproc’ does not name a type
src/pykcs11_wrap.cpp:927: error: ‘PyObject’ was not declared in this scope
src/pykcs11_wrap.cpp:927: error: ‘x’ was not declared in this scope
src/pykcs11_wrap.cpp:927: error: expected primary-expression before ‘void’
src/pykcs11_wrap.cpp:927: error: initializer expression list treated as compound expression
src/pykcs11_wrap.cpp:928: error: expected ‘,’ or ‘;’ before ‘{’ token
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include /c++/4.4.7/stdexcept:38,
from src/pykcs11_wrap.cpp:3074:
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:3 5: error: expected declaration before end of line
error: command 'gcc' failed with exit status 1
make: *** [build-stamp] Error 1
Sorry for the insanely long stack trace. Wasn't sure how to condense it so it was showing the right error messages for a possbile solution. Anyway, here's what i get when I run my python script in the remote machine.
I believe the problem to be with finding the correct compiler, but I'm not entirely sure.
Furthermore I tried to import PyKCS11 when invoking the interpreter to see a more simplified version of the error.
>>> import PyKCS11
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "PyKCS11/__init__.py", line 20, in <module>
import PyKCS11.LowLevel
File "PyKCS11/LowLevel.py", line 39, in <module>
LowLevel = swig_import_helper()
File "PyKCS11/LowLevel.py", line 31, in swig_import_helper
import _LowLevel
ImportError: No module named _LowLevel
I am trying to convert a PDF to a JPG preview, but certain PDF files are taking a really long time to process on our RH Linux server (+- 35 seconds). The same file & command on my Windows 8 development machine takes only 3 seconds. I am using GraphicsMagick 1.3.18 & GhostScript 8.70-19. I get the same results using ImageMagick. Unfortunately I can't share the PDF file in question, but here are its properties (it is only 399KB compressed & 1.1MB uncompressed):
I tested using a compressed & uncompressed version, and the results are similar. I found that both the gm convert file.pdf output.jpg and gm identify file.pdf commands take a long time.
This is the output of gm identify -version on the Linux server:
GraphicsMagick 1.3.18 2013-03-10 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2013 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP yes
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG no
JPEG-2000 yes
JPEG yes
Little CMS yes
Loadable Modules yes
OpenMP yes (200805)
PNG yes
TIFF yes
TRIO no
UMEM no
WMF yes
X11 yes
XML yes
ZLIB yes
Host type: x86_64-redhat-linux-gnu
Configured using the command:
./configure '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--enable-shared' '--disable-static' '--with-lcms' '--with-magick_plus_plus' '--with-modules' '--with-perl' '--with-perl-options=INSTALLDIRS=vendor ' '--with-threads' '--with-wmf' '--with-x' '--with-xml' '--without-dps' '--without-gslib' '--with-gs-font-dir=/usr/share/fonts/default/Type1' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=
Final Build Parameters:
CC = gcc -std=gnu99
CFLAGS = -fopenmp -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -pthread
CPPFLAGS = -I/usr/include/freetype2 -I/usr/include/libxml2
CXX = g++
CXXFLAGS = -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -pthread
LDFLAGS = -L/usr/lib -L/usr/lib
LIBS = -llcms -lfreetype -lXext -lSM -lICE -lX11 -lbz2 -lz -lltdl -lm -lgomp -lpthread
I only have this problem for some PDF files, most are processed using the same command quite quickly.
Any ideas regarding what might make this take so long?
i am trying to use free type in android native and i am trying to follow this tutorial: http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Android#FreeType which seems to be the standard tutorial that everyone links to.
my problem now is that i have never cross compiled anything before and when i try to prepare the cross-compiler with: make-standalone-toolchain.sh ... in cygwin (im on windows 7) i get:
-bash: make-standalone-toolchain.sh: command not found
even though it definitely is there. what am i missing? or is that not to be done in cygwin at all but somewhere else? this standard tutorial is not detailed enough for me, can anyone give me a more detailed explanation on where i have to give those commands?
I have managed to compile and use freetype 2.7.1 library in ndk with CMake:
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# freetype 2.7.1
add_definitions(-DFT2_BUILD_LIBRARY)
set(FTDIR "src/main/cpp/freetype")
include_directories(${FTDIR}/include)
set(FTSRC
${FTDIR}/src/autofit/autofit.c
${FTDIR}/src/base/ftbase.c
${FTDIR}/src/base/ftbbox.c
${FTDIR}/src/base/ftbdf.c
${FTDIR}/src/base/ftbitmap.c
${FTDIR}/src/base/ftcid.c
${FTDIR}/src/base/ftfntfmt.c
${FTDIR}/src/base/ftfstype.c
${FTDIR}/src/base/ftgasp.c
${FTDIR}/src/base/ftglyph.c
${FTDIR}/src/base/ftgxval.c
${FTDIR}/src/base/ftinit.c
${FTDIR}/src/base/ftlcdfil.c
${FTDIR}/src/base/ftmm.c
${FTDIR}/src/base/ftotval.c
${FTDIR}/src/base/ftpatent.c
${FTDIR}/src/base/ftpfr.c
${FTDIR}/src/base/ftstroke.c
${FTDIR}/src/base/ftsynth.c
${FTDIR}/src/base/ftsystem.c
${FTDIR}/src/base/fttype1.c
${FTDIR}/src/base/ftwinfnt.c
${FTDIR}/src/bdf/bdf.c
${FTDIR}/src/bzip2/ftbzip2.c
${FTDIR}/src/cache/ftcache.c
${FTDIR}/src/cff/cff.c
${FTDIR}/src/cid/type1cid.c
${FTDIR}/src/gzip/ftgzip.c
${FTDIR}/src/lzw/ftlzw.c
${FTDIR}/src/pcf/pcf.c
${FTDIR}/src/pfr/pfr.c
${FTDIR}/src/psaux/psaux.c
${FTDIR}/src/pshinter/pshinter.c
${FTDIR}/src/psnames/psnames.c
${FTDIR}/src/raster/raster.c
${FTDIR}/src/sfnt/sfnt.c
${FTDIR}/src/smooth/smooth.c
${FTDIR}/src/truetype/truetype.c
${FTDIR}/src/type1/type1.c
${FTDIR}/src/type42/type42.c
${FTDIR}/src/winfonts/winfnt.c
${FTDIR}/src/base/ftdebug.c
${FTDIR}/include/ft2build.h
${FTDIR}/include/freetype/config/ftconfig.h
${FTDIR}/include/freetype/config/ftheader.h
${FTDIR}/include/freetype/config/ftmodule.h
${FTDIR}/include/freetype/config/ftoption.h
${FTDIR}/include/freetype/config/ftstdlib.h
)
add_library( freetype SHARED ${FTSRC} )
and then you link it to your ndk library : e.g.
add_library(native-lib SHARED src/main/cpp/native-lib.cpp)
target_link_libraries(native-lib freetype)
you can't just run .sh script in windows environment... You have to use sh.exe utility to strat your script... somethiong like:
path_to_cygwin\bin\sh make-standalone-toolchain.sh [options]
on macos platform:
build64
#!/bin/bash
export NDK= /Users/xxxxx/Library/Android/sdk/ndk/21.3.6528147 # set your path
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
SYSROOT=$TOOLCHAIN/sysroot
export API=21
export TARGET=aarch64-linux-android
CPU=arm64-v8a
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
# old
#export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=aarch64-none-linux-android21 --gcc-toolchain=$TOOLCHAIN "
# with -g
export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
# without -g
#export CFLAGS="-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
export AR=$TOOLCHAIN/bin/llvm-ar
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
PREFIX=$(pwd)/android/$CPU
function build
{
./configure \
--host=$TARGET \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--without-brotli \
--with-zlib=no \
--with-bzip2=no \
--with-png=no \
--with-harfbuzz=no \
--with-sysroot=$SYSROOT \
make -j12 VERBOSE=1
make install
}
build
build32
#!/bin/bash
export NDK=/Users/xxxxx/Library/Android/sdk/ndk/21.3.6528147 # set your path
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
SYSROOT=$TOOLCHAIN/sysroot
export API=21
export TARGET=armv7a-linux-androideabi
CPU=armeabi-v7a
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
# old
#export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=aarch64-none-linux-android21 --gcc-toolchain=$TOOLCHAIN "
# with -g
export CFLAGS="-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
# without -g
#export CFLAGS="-DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -O3 -DNDEBUG -fPIC --target=$TARGET$API --gcc-toolchain=$TOOLCHAIN "
export AR=$TOOLCHAIN/bin/llvm-ar
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
PREFIX=$(pwd)/android/$CPU
function build
{
./configure \
--host=$TARGET \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--without-brotli \
--with-zlib=no \
--with-bzip2=no \
--with-png=no \
--with-harfbuzz=no \
--with-sysroot=$SYSROOT \
make -j12 VERBOSE=1
make install
}
build