I need to use the R package Rglpk in a project and need to modify the package - in particular, I need to add a time limit control parameter option to the interface (it is a option in GLPK v4.5.2 itself, but Rglpk 0.5-2 does not support this parameter). This will allow R to call GLPK and limit the search time to be user specified (i.e., search time <= t).
I have modified Rglpk code and have successfully compiled the package on Mac OS X v10.9.2 and verified that it worked as expected. My project needs to run on Windows and I have not been able to compile the modified Rglpk package, or for that matter the unmodified package (Rglpk 0.5-2), on Windows. I have tried uploading the original package to Win Builder (http://win-builder.r-project.org/), but I have received the same errors.
The following is a summary of what I have done on Windows 7 (my machine):
(1) Download the Rglpk 0.5-2 package source from http://cran.r-project.org/web/packages/Rglpk/index.html
(2) Unzip the file to a directory. All the code is in a directory called Rglpk.
(3) Start RStudio v0.98.490. I have devtools v1.4.1 installed, Rtools v3.1 installed, and R v3.0.2
(4) Open a new project and select the Rglpk directory mentioned in (2).
(5) Under the 'Build' menu, select 'Build and Reload'. The result of this is that the package compiles and is loaded:
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (Rglpk)
(6) Under the 'Build' menu, select 'Check Package'. The result is that the installation fails. The log file is shown below.
I have tried to compile another package that has C code and have not been able to compile it either. The package I tried to compile is devtools v1.5 The error that came back in that case is 'LoadLibrary failure: %1 is not a valid Win32 application.'
Does anyone have any experience compiling R packages on Windows that include C code? I have been able to compile packages that involve only R code, but it seems C code is troublesome.
Any help would be appreciated.
Log File
* using R version 3.0.2 (2013-09-25)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'Rglpk/DESCRIPTION' ... OK
* this is package 'Rglpk' version '0.5-2'
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... NOTE
Found the following apparent object files/libraries:
src/GLPK/alloc.o src/GLPK/amd/amd_1.o src/GLPK/amd/amd_2.o
src/GLPK/amd/amd_aat.o src/GLPK/amd/amd_control.o
src/GLPK/amd/amd_defaults.o src/GLPK/amd/amd_dump.o
src/GLPK/amd/amd_info.o src/GLPK/amd/amd_order.o
src/GLPK/amd/amd_post_tree.o src/GLPK/amd/amd_postorder.o
src/GLPK/amd/amd_preprocess.o src/GLPK/amd/amd_valid.o
src/GLPK/bignum.o src/GLPK/cfg.o src/GLPK/cfg1.o
src/GLPK/colamd/colamd.o src/GLPK/dmp.o src/GLPK/env.o
src/GLPK/error.o src/GLPK/ffalg.o src/GLPK/fhv.o src/GLPK/fhvint.o
src/GLPK/glpapi01.o src/GLPK/glpapi02.o src/GLPK/glpapi03.o
src/GLPK/glpapi04.o src/GLPK/glpapi05.o src/GLPK/glpapi06.o
src/GLPK/glpapi07.o src/GLPK/glpapi08.o src/GLPK/glpapi09.o
src/GLPK/glpapi10.o src/GLPK/glpapi11.o src/GLPK/glpapi12.o
..... (more lines are here, I have removed them for brevity)
src/GLPK/triang.o src/GLPK/wclique.o src/GLPK/wclique1.o
src/GLPK/zlib/adler32.o src/GLPK/zlib/compress.o
src/GLPK/zlib/crc32.o src/GLPK/zlib/deflate.o src/GLPK/zlib/gzclose.o
src/GLPK/zlib/gzlib.o src/GLPK/zlib/gzread.o src/GLPK/zlib/gzwrite.o
src/GLPK/zlib/inffast.o src/GLPK/zlib/inflate.o
src/GLPK/zlib/inftrees.o src/GLPK/zlib/trees.o
src/GLPK/zlib/uncompr.o src/GLPK/zlib/zio.o src/GLPK/zlib/zutil.o
Object files/libraries should not be included in a source package.
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking whether package 'Rglpk' can be installed ... ERROR
Installation failed.
The contents of the 00install.out file are:
* installing *source* package 'Rglpk' ...
** libs
*** arch - i386
gcc -m32 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG -IGLPK -IGLPK/amd -IGLPK/colamd -IGLPK/minisat -IGLPK/proxy -IGLPK/zlib -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rglpk_initialize.c -o Rglpk_initialize.o
gcc -m32 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG -IGLPK -IGLPK/amd -IGLPK/colamd -IGLPK/minisat -IGLPK/proxy -IGLPK/zlib -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rglpk_read_file.c -o Rglpk_read_file.o
Rglpk_read_file.c: In function 'Rglpk_read_file':
Rglpk_read_file.c:84:6: warning: 'status' may be used uninitialized in this function [-Wuninitialized]
Rglpk_read_file.c: In function 'Rglpk_retrieve_MP_from_file':
Rglpk_read_file.c:192:6: warning: 'status' may be used uninitialized in this function [-Wuninitialized]
gcc -m32 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG -IGLPK -IGLPK/amd -IGLPK/colamd -IGLPK/minisat -IGLPK/proxy -IGLPK/zlib -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Rglpk_solve.c -o Rglpk_solve.o
Rglpk_solve.c: In function 'R_glp_solve':
Rglpk_solve.c:25:10: warning: variable 'kl' set but not used [-Wunused-but-set-variable]
gcc -m32 -shared -s -static-libgcc -o Rglpk.dll tmp.def Rglpk_initialize.o Rglpk_read_file.o Rglpk_solve.o GLPK/libglpk.a -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.2/bin/i386 -lR
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `GLPK/libglpk.a(glpmpl04.o)' is incompatible with i386 output
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `GLPK/libglpk.a(error.o)' is incompatible with i386 output
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `GLPK/libglpk.a(glpmpl03.o)' is incompatible with i386 output
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `GLPK/libglpk.a(alloc.o)' is incompatible with i386 output
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `GLPK/libglpk.a(glpenv07.o)' is incompatible with i386 output
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe:
.....
Error: 64-bit reloc in dll
Error: 64-bit reloc in dll
Error: 64-bit reloc in dll
.....
Rglpk_initialize.o:Rglpk_initialize.c:(.text+0x33): undefined reference to `glp_term_hook'
Rglpk_initialize.o:Rglpk_initialize.c:(.text+0x44): undefined reference to `glp_version'
Rglpk_read_file.o:Rglpk_read_file.c:(.text+0x10): undefined reference to `glp_delete_prob'
Rglpk_read_file.o:Rglpk_read_file.c:(.text+0x4f): undefined reference to `glp_term_out'
Rglpk_read_file.o:Rglpk_read_file.c:(.text+0x60): undefined reference to `glp_delete_prob'
Rglpk_read_file.o:Rglpk_read_file.c:(.text+0x65): undefined reference to `glp_create_prob'
.....
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x4326): undefined reference to `strcpy'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x4d39): undefined reference to `strcpy'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x4dc5): undefined reference to `strcpy'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x4e05): undefined reference to `floor'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x4e16): undefined reference to `floor'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x502e): undefined reference to `floor'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x50e2): undefined reference to `sprintf'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x5111): undefined reference to `sprintf'
.....
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x990): undefined reference to `exp'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0x9e0): undefined reference to `log'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0xa30): undefined reference to `log10'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0xaee): undefined reference to `sin'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0xb4e): undefined reference to `cos'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0xb65): undefined reference to `atan'
GLPK/libglpk.a(glpmpl03.o):glpmpl03.c:(.text+0xb79): undefined reference to `atan2'
.....
GLPK/libglpk.a(deflate.o):deflate.c:(.text+0x2ec0): undefined reference to `memcpy'
GLPK/libglpk.a(deflate.o):deflate.c:(.text+0x2ed5): undefined reference to `memcpy'
GLPK/libglpk.a(deflate.o):deflate.c:(.text+0x2ee7): undefined reference to `memcpy'
GLPK/libglpk.a(zutil.o):zutil.c:(.text+0x47): undefined reference to `malloc'
GLPK/libglpk.a(zutil.o):zutil.c:(.text+0x54): undefined reference to `free'
collect2: ld returned 1 exit status
ERROR: compilation failed for package 'Rglpk'
It looks like a couple things are going wrong:
Object files are getting pre-compiled, but not cleaned out.
Because these object files are being pre-compiled, and it looks like they were compiled for 64-bit architecture, when you try to use these in a 32-bit build, the installation process barfs.
The fix here is going to be deleting all of those *.o files (they need to be compiled as part of the R CMD build step, I imagine), and the resulting tarball can then be R CMD checked.
You should consider installing a more up-to-date version of RStudio and devtools, and ensure you use devtools to handle the build process -- it might be able to help you out here.
Related
When trying to install the latest glibc into my machine provided I executed the "config" executable with flags: ../configure CFLAGS="-O3 -fPIC" --disable-sanity-checks it generates the makefile correctly, although I think disable-sanity-checks will give some errors.
But whenever I try to execute the generated Makefile using make, the console prints the following error:
make[3]: Leaving directory '/mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/elf'
gcc -nostdlib -nostartfiles -shared -o /mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/glibc-build/elf/ld.so.new \
-Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs \
/mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/glibc-build/elf/librtld.os -Wl,--version-script=/mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/glibc-build/ld.map
\
-Wl,-soname=ld-linux-x86-64.so.2 \
-Wl,-defsym=_begin=0
/mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/glibc-build/elf/librtld.os: In function `process_envvars':
/mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/elf/rtld.c:2686: undefined reference to `__GI___open64_nocancel'
/usr/bin/ld: /mnt/c/Users/SCP173/Downloads/Thread/glib/glibc/glibc-build/elf/librtld.os: relocation R_X86_64_PC32 against undefined symbol `__GI___open64_nocancel' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
As I said, I tried to add the -fPIC flag but still didn't catch it. And I'm kind of new to .os, .map and other extensions such as those. Am I doing it completely wrong? Or else, how could I compile just that file using gcc instead of passing the flag to the whole make command?
Your file system is not set up correctly. By default, NTFS is case-preserving, but case-insensitive. As far as I understand it, current versions of WSL set up only part of the file system tree in case-sensitive mode. (A previous system-wide configuration is now disregarded.)
Building glibc requires a case-sensitive file system. Please also note that WSL is not a proper development environment for glibc because there are so many test failures due to bugs in the WSL kernel emulation.
I'm trying to install AODV protocol on Raspberry pi. After completing git clone from "https://github.com/erimatnor/aodv-uu" when I tried to do "make" and I am getting below error. Expecting your suggestion. Thank you!
make
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY -DDEBUG -o aodvd main.o list.o debug.o timer_queue.o aodv_socket.o aodv_hello.o aodv_neighbor.o aodv_timeout.o routing_table.o seek_list.o aodv_rreq.o aodv_rrep.o aodv_rerr.o nl.o locality.o
aodv_neighbor.o: In function neighbor_add':
/home/pi/aodv-uu/aodv_neighbor.c:68: undefined reference tohello_update_timeout'
aodv_timeout.o: In function route_discovery_timeout':
/home/pi/aodv-uu/aodv_timeout.c:98: undefined reference tort_table_update_timeout'
aodv_rreq.o: In function rreq_route_discovery':
/home/pi/aodv-uu/aodv_rreq.c:460: undefined reference tort_table_update_timeout'
aodv_rreq.o: In function rreq_local_repair':
/home/pi/aodv-uu/aodv_rreq.c:521: undefined reference tort_table_update_timeout'
aodv_rrep.o: In function rrep_forward':
/home/pi/aodv-uu/aodv_rrep.c:231: undefined reference tort_table_update_timeout'
nl.o: In function nl_kaodv_callback':
/home/pi/aodv-uu/nl.c:282: undefined reference tort_table_update_timeout'
collect2: error: ld returned 1 exit status
Makefile:112: recipe for target 'aodvd' failed
make: *** [aodvd] Error 1
The code available from sourceforge is the same code that is on github. If you download the archive, you'll see that the latest modification date of any file there is 2010. Given the age of this code, I wouldn't be surprised to find that things simply don't work anymore.
However, here's a quick workaround for your problem. The root cause appears to be that the problem functions, like rt_table_update_timeout, are declared as inline, but that information seems to get lost somewhere in the build process such that other object files are trying to reference these as non-inline functions.
You can avoid this by opening defs.h, looking for this line:
#define NS_INLINE inline
And replace it with:
#define NS_INLINE
This will allow aodvd to compile correctly (make aodvd). On my system, the kernel module will subsequently fail to compile:
cc1: fatal error: /lib/modules/4.13.15-100.fc25.x86_64/build/include/linux/modversions.h: No such file or directory
As far as I can tell, the modversions.h file is no longer produced by modern Linux kernels.
I wrote a program (myreader.c) to manipulate a RFID reader.
I compile by type "make" in the root of the package, makefile is shown below
# CC and CFLAGS are varilables
CC=gcc
CFLAGS = -c
# -c option ask g++ to compile the source files, but do not link.
# -g option is for debugging version
# -O2 option is for optimized version
OPTFLAGS = -O2 -g
myreader : src/myreader.c
$(CC) $(OPTFLAGS) src/myreader.c src/crypto1.c src/nfc-utils.c -lnfc -o ./bin/myreader
# clean all the .o and executable files
clean:
rm -rf bin/myreader
and it works well on my original machine(64 bits, Ubuntu 12.04 LTS), and the only problem is, when I type make, the warning info would come up.
src/myreader.c:519:6: warning: conflicting types for ‘printResult’ [enabled by default]
src/myreader.c:211:3: note: previous implicit declaration of ‘printResult’ was here
But /bin/myreader works well.
However, when I move the package to another machine(64 bits, Ubuntu 11.10), and type make in the same way as in the original machine.
Error messages in the below appears:
berln#ubuntu:~/桌面/useful code$ make
gcc -O2 -g src/myreader.c src/crypto1.c src/nfc-utils.c -lnfc -o ./bin/myreader
src/myreader.c:519:6: warning: conflicting types for ‘printResult’ [enabled by default]
src/myreader.c:211:3: note: previous implicit declaration of ‘printResult’ was here
/tmp/ccrKvhjm.o: In function `mf_enhanced_auth':/home/berln/桌面/useful code/src/myreader.c:373: undefined reference to `nfc_configure'
/home/berln/桌面/useful code/src/myreader.c:380: undefined reference to `nfc_configure'
/home/berln/桌面/useful code/src/myreader.c:390: undefined reference to `nfc_configure'
/home/berln/桌面/useful code/src/myreader.c:434: undefined reference to `nfc_configure'
/tmp/ccrKvhjm.o: In function `mf_configure':
/home/berln/桌面/useful code/src/myreader.c:484: undefined reference to `nfc_configure'
/tmp/ccrKvhjm.o:/home/berln/桌面/useful code/src/myreader.c:489: more undefined references to `nfc_configure' follow
/tmp/ccrKvhjm.o: In function `main':
/home/berln/桌面/useful code/src/myreader.c:155: undefined reference to `nfc_connect'
/home/berln/桌面/useful code/src/myreader.c:213: undefined reference to `nfc_disconnect'
collect2: ld returned 1 exit status
make: *** [myreader] Error 1
I have no ideas why this error happened on only one machine instead of both.
If you need more information, you can download the package here.
Thanks in advance.
It seems the problem is in the nfc library, but the linker doesn't complain that it's missing, so something wrong with it. Try to recompile it. If it's a package check that it's the same version as on the other server.
Most likely your nfc library is missing or not installed properly on your other computer.
One of the options you pass to the linker is -lnfc, which tells it to link to the nfc library. Your errors are coming from the linker, which cannot find the nfc_configure and other nfc_ symbols. This means that the linker cannot find these symbols. Check the nfc library installation.
I had a problem with adding reference in my C application. I am unable to add linker reference to "libiconv" in my data compresser project.I have download "libiconv" library but confuse in adding reference which show error in compiling.I'm using Dev C++ for developing my compression apps.
here is the compile log:
Building Makefile: "C:\Dev-Cpp\Examples\eottest\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Examples\eottest\Makefile.win" all
gcc.exe eot.o libeot.o properties.o -o "Project1.exe" -L"C:/Dev-Cpp/lib"
libeot.o(.text+0x19):libeot.c: undefined reference to `libiconv_open'
libeot.o(.text+0x36):libeot.c: undefined reference to `libiconv_close'
libeot.o(.text+0x67):libeot.c: undefined reference to `libiconv'
collect2: ld returned 1 exit status`
You're only specifying an additional library path, not the actual library to link to. Try:
gcc.exe eot.o libeot.o properties.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -liconv
I am trying to run the C files downloaded from here as follows :
gcc main.c docs_file.txt ksg_file.txt
However, I receive the following error:
/usr/bin/ld:docs_file.txt: file format not recognized; treating as linker script
/usr/bin/ld:docs_file.txt:2: syntax error
collect2: ld returned 1 exit status
I am not sure what the problem is.
Update 1:
I get the following errors while compiling:
gcc main.c -o ksg
/tmp/cc4H83rG.o: In function `main':
main.c:(.text+0xa5): undefined reference to `stree_new_tree'
main.c:(.text+0xe0): undefined reference to `stree_add_string'
main.c:(.text+0x2a7): undefined reference to `stree_match'
main.c:(.text+0x38f): undefined reference to `int_stree_set_idents'
main.c:(.text+0x422): undefined reference to `int_stree_get_parent'
main.c:(.text+0x47b): undefined reference to `int_stree_get_suffix_link'
/tmp/cc4H83rG.o: In function `count_freq':
main.c:(.text+0x96d): undefined reference to `int_stree_set_idents'
main.c:(.text+0x9a8): undefined reference to `stree_get_num_leaves'
main.c:(.text+0xa91): undefined reference to `int_stree_set_idents'
/tmp/cc4H83rG.o: In function `select_feature':
main.c:(.text+0xb34): undefined reference to `int_stree_set_idents'
main.c:(.text+0xbe7): undefined reference to `stree_get_num_children'
main.c:(.text+0xc47): undefined reference to `int_stree_get_parent'
main.c:(.text+0xc67): undefined reference to `int_stree_set_idents'
main.c:(.text+0xc94): undefined reference to `int_stree_get_parent'
main.c:(.text+0xdbb): undefined reference to `int_stree_get_suffix_link'
main.c:(.text+0xddb): undefined reference to `int_stree_set_idents'
main.c:(.text+0xe08): undefined reference to `int_stree_get_suffix_link'
collect2: ld returned 1 exit status
The tarball you linked to contains source code. To run the code you need to compile it into an executable. You can then run the executable if the compilation succeeds.
Here are the files you should have to start with, directly from the tar file:
$ ls
ksg main.c sample_ksgs.txt stree.h
ksg.exe sample_docs.txt stree.c stree.txt
Compile
First we'll compile the program. The -o ksg names the executable ksg. When gcc displays nothing that means it succeeded without any errors or warnings.
$ gcc -o ksg main.c stree.c
Run
Now we can run the ksg executable we just created. The command-line syntax is ./ksg <arguments>. For example, we can ask for help with ./ksg -?:
$ ./ksg -?
Dell Zhang, Wee Sun Lee.
Extracting Key-Substring-Group Features for Text Classification.
In Proceedings of the 12th ACM SIGKDD International Conference on
Knowledge Discovery and Data Mining (KDD),
Philadelphia, PA, Aug 2006.
Usage: ksg [options] docs_file ksgs_file
Options:
-? -> help
-s [0,1] -> assume white-spaces are word delimiters
(default 1)
-l [2..] -> the minimum frequency
(default 2)
-h [l..] -> the maximum frequency
(default 8,000)
-b [2..] -> the minimum number of branches
(default 2)
-p (0..1] -> the maximum parent-child conditional probability
(default 1.0)
-q (0..1] -> the maximum suffix-link conditional probability
(default 1.0)
Arguments:
docs_file -> the input file with each line as a raw document
ksgs_file -> the output file with each line as a bag of ksg features
Usually, gcc can compile only .c files - which, by convention, hold C code inside them.
.txt files are usually plain text. For human eyes only.
Try
gcc *.c
With C, you don't run a program using the compiler.
You first compile the C file to a binary (gcc main.c -o binary).
Then you execute it (./binary docs_file.txt ksg_file.txt).