I just installed g++ from cygwin, when I try to compile a C++ file I am not getting any executable produced by the compiler, see example below. What's going wrong?
Directory of C:\helloworld
01/02/2011 04:50 PM .
01/02/2011 04:50 PM ..
01/02/2011 04:48 PM 94 helloworld.cpp
1 File(s) 94 bytes
2 Dir(s) 24,658,272,256 bytes free
C:\helloworld>g++-4 helloworld.cpp
C:\helloworld>dir
Volume in drive C is OS
Volume Serial Number is C47B-942D
Directory of C:\helloworld
01/02/2011 04:50 PM .
01/02/2011 04:50 PM ..
01/02/2011 04:48 PM 94 helloworld.cpp
1 File(s) 94 bytes
2 Dir(s) 24,657,747,968 bytes free
C:\helloworld>
For others who end up here with g++ producing no output.
I solved it by running cygcheck -s in the cygwin terminal window. This checks (amongst others) for multiple instances of cygwin1.dll. In my case WinAVR was causing problems, uinstalling did the the trick
This link was also helpful in getting Cygwin to run properly: http://thehacklist.blogspot.nl/2009/04/cygwin-ls-command-not-found.html
The problem seems to be (judging from your C:\ prompt) that you are not running Cygwin. Try double-clicking the Cygwin icon.
You should be able to run any Cygwin program from the DOS prompt since Cygwin is not an operating system like Linux, it is primarily a special DLL that programs link against + tools. However, in this case, I suspect that path issues are preventing g++ from running, either the path to g++ itself or to some libs g++ requires. Cygwin apps are notoriously bad at giving any info when they don't run, and the solution is to run them via strace.
C:\cygwin\bin> strace g++
Then any issues will be shown in a windows dialog box.
Related
I am trying to build a sample project for avr atmega328p. And I am facing a strange issue. I have following directory structure.
inc/core/device_support.h
src/main.c
src/core/device_support.c
I have two project setups, one using make and another one using cmake. When I build using make everything works fine. but when I use cmake it doesn't compile ok. ( .text section is not same if I run avr-size -A myProject.elf and it doesn't run correctly on target mcu). But if I run the compile command manually in cmake project directory with build directory as working directory everything works fine.
I have narrowed down the problem to the fact that if we run compile command form core /home/user/avr/build/core it doesn't work, and If I run command while in /home/user/avr/build build directory It works fine. I have no clue to why this may be happening.
My question is why being on different directory messes up compilation and how can I fix it in cmake.
with make I have something like:
avr-gcc -DARDUINO=10808 -DF_CPU=160000000L -I/home/user/avr/inc/core -mmcu=atmega328p -ffunction-sections -fdata-sections -MMD -flto -std=gnu11 -fno-fat-lto-objects -Os -w -g -MD -MT /home/user/avr/src/core/device_support.c -o /home/user/avr/build/core/device_support.o
and with cmake auto generated script I have:
cd /home/user/avr/build/core && avr-gcc -DARDUINO=10808 -DF_CPU=160000000L -I/home/user/avr/inc/core -mmcu=atmega328p -ffunction-sections -fdata-sections -MMD -flto -std=gnu11 -fno-fat-lto-objects -Os -w -g -MD -MT -o src/CMakeFiles/core.dir/src/core/device_support.o /home/user/avr/src/core/device_support.c
UPDATE 01:
avr-size -A myProject.elf output (cmake):
section size addr
.data 0 8388864
.text 740 0
.bss 9 8388864
.comment 17 0
.note.gnu.avr.deviceinfo 64 0
.debug_aranges 120 0
.debug_info 3537 0
.debug_abbrev 1965 0
.debug_line 1044 0
.debug_frame 124 0
.debug_str 1175 0
.debug_loc 843 0
.debug_ranges 40 0
Total 9678
avr-size -A myProject.elf output (make):
section size addr
.data 0 8388864
.text 930 0
.bss 9 8388864
.comment 17 0
.note.gnu.avr.deviceinfo 64 0
.debug_aranges 104 0
.debug_info 3559 0
.debug_abbrev 2002 0
.debug_line 1134 0
.debug_frame 180 0
.debug_str 1139 0
.debug_loc 1154 0
.debug_ranges 24 0
Total 10316
You can see the difference in .text section. Its a simple led blink code When I run this on device in cmake case LED stays on at sometimes and completely off at others. And If I compile the same code manually by running the same commands from cmake's output, but with build directory as my working directory then LED blinks as expected.
There are no errors during build in either case. The only difference is being in build directory. If I build manually and my working directory is not build then It fails in this case as well. For some reason being in build directory during compilation is important and I have no clue why.
Update 02:
Example code has been upload to : https://github.com/systemangle/mcve_avr
Please see project readme.
For some reason being in build directory during compilation is important and I have no clue why
Then you probably already have the answer. The problem doesn't seem to be CMake related.
May be you can try an in-source build with cmake and see what happen.
Otherwise if you want to mimic the hand-written Makefile behaviour you can avoid using any add_subdirectory and only write a big fat CMakeLists.txt at the root of your project.
All that said, if compilation output vary depending on where you are when the compiler is invoked then I think you'd better off asking question to the people providing the cross-compiler about this weird behavior.
Did you try hand compilation a file while being in a different directory?
Does this change the outputed object file?
This is on 64-bit Windows 10 Pro with MSVC 2015. This question has a long body because I want to give full information up front, but the actual question is rather straightforward:
How can I get panda to keep the working directory around (like cpanmdoes) after an install failure so I can diagnose what went wrong?
As you can see from the log below, linenoise.dll seems to be created in the right place, but come install time, it is nowhere to be found.
The .panda-work directory in %TEMP% is gone.
I just built Rakudo from source by doing
git clone git://github.com/rakudo/rakudo.git
cd rakudo
set CFLAGS=/O2 /favor:INTEL64 /Qpar
perl Configure.pl --gen-moar --gen-nqp --backends=moar --prefix=c:/opt/perl6
nmake test
nmake install
nmake spectest ← The number of failures has gone up since the last time I tried this, but that's not related to my question
Then I installed panda by doing:
git clone --recursive git://github.com/tadzik/panda.git
cd panda
perl6 bootstrap.pl
which worked.
Then I did
panda install Task::Star
I got a test failure:
==> Building NativeHelpers::Blob
==> Testing NativeHelpers::Blob
t/00-trivial.t ..
Dubious, test returned 5 (wstat 1280, 0x500)
Failed 1/1 subtests
but I force installed that because I wanted to get to as complete an install as possible as quickly as possible.
So, forging ahead, I hit this:
C:\Users\...\Temp> panda install Linenoise
==> Fetching Linenoise
==> Building Linenoise
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c /nologo /MT /Ox /GL /DNDEBUG /DWIN32 /DAO_ASSUME_WINDOWS98 /O2 /favor:INTEL64 /Qpar /Folinenoise.obj linenoise.c
linenoise.c
perl6 -e "mkdir 'resources'; mkdir 'resources/libraries'"
link /dll /nologo /LTCG shell32.lib ws2_32.lib mswsock.lib rpcrt4.lib advapi32.lib psapi.lib iphlpapi.lib userenv.lib /out:resources/libraries/libline
noise.dll linenoise.obj
Generating code
Finished generating code
cl /Foconstant-helper /nologo /MT /Ox /GL /DNDEBUG /DWIN32 /DAO_ASSUME_WINDOWS98 /O2 /favor:INTEL64 /Qpar constant-helper.c
constant-helper.c
Generating code
Finished generating code
perl6 fill-constants.pl lib/Linenoise.pm
==> Testing Linenoise
==> Installing Linenoise
Failed to open file C:\Users\...\Temp\.panda-work\1483278033_1\resources\libraries\linenoise.dll: no such file or directory
in any at C:\opt\perl6/share/perl6/runtime/CORE.setting.moarvm line 1
in block at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 61
in sub indir at C:\opt\perl6\share\perl6\site\sources\24811C576EF8F85E7672B26955C802BB2FC94675 (Panda::Common) line 20
in method install at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 42
in method install at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 190
in method resolve at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 263
in sub MAIN at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 20
in block at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 165
Actually thrown at:
in method throw at C:\opt\perl6/share/perl6/runtime/CORE.setting.moarvm line 1
in any at gen/moar/Metamodel.nqp line 3072
in block at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 61
in sub indir at C:\opt\perl6\share\perl6\site\sources\24811C576EF8F85E7672B26955C802BB2FC94675 (Panda::Common) line 20
in method install at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 42
in method install at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 190
in method resolve at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 263
in sub MAIN at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 20
in block at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 165
The Build.pm file for Linenoise is simply not written correctly. They are hard-coding the 'lib' prefix to the library name while also trying to use the platform library name guessing mechanism in another part. If it wants to use $*VM.platform-library-name then it needs to generate a file named linenoise.dll, not liblinenoise.dll
I'm also not sure that Linenoise works on windows even if it did install.
You should probably be using zef instead of panda. If you were, you could view the working directory used at ~/.zef/store/p6-linenoise.git
I'm trying to follow the instructions at syntaxnet's github page to build syntaxnet parser models.
My system is a Debian Wheezy. Shouldn't be very different from Ubuntu 14.04 LTS or 15.05. I have compiled bazel 0.2.2 (as opposed to 0.2.2b) from source and it appears to work correctly.
Whenever I launch the bazel test syntaxnet/... util/utf8/... command, no tests are executed (all skipped) with some quite cryptic error messages. Here's an example:
root#host:~/tensorflow_syntaxnet/models/syntaxnet# ../../bazel/output/bazel test syntaxnet/... util/utf8/...
Extracting Bazel installation...
.............
INFO: Found 65 targets and 12 test targets...
ERROR: /root/.cache/bazel/_bazel_root/74c6bab7a21f28ad02405b720243d086/external/six_archive/BUILD:1:1: Executing genrule #six_archive//:copy_six failed: namespace-sandbox failed: error executing command /root/.cache/bazel/_bazel_root/74c6bab7a21f28ad02405b720243d086/syntaxnet/_bin/namespace-sandbox ... (remaining 5 argument(s) skipped).
unshare failed with EINVAL even after 101 tries, giving up.
INFO: Elapsed time: 95.469s, Critical Path: 22.46s
//syntaxnet:arc_standard_transitions_test NO STATUS
//syntaxnet:beam_reader_ops_test NO STATUS
//syntaxnet:graph_builder_test NO STATUS
//syntaxnet:lexicon_builder_test NO STATUS
//syntaxnet:parser_features_test NO STATUS
//syntaxnet:parser_trainer_test NO STATUS
//syntaxnet:reader_ops_test NO STATUS
//syntaxnet:sentence_features_test NO STATUS
//syntaxnet:shared_store_test NO STATUS
//syntaxnet:tagger_transitions_test NO STATUS
//syntaxnet:text_formats_test NO STATUS
//util/utf8:unicodetext_unittest NO STATUS
Executed 0 out of 12 tests: 12 were skipped.
I'm using Oracle Java 8 JDK as recommended, and my compiler is:
~/tensorflow_syntaxnet/models/syntaxnet# gcc --version
gcc (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Tried looking into the namespace-sandbox binary that's mentioned in the error message, but before I dive deep into this, I thought I'd ask here.
~/tensorflow_syntaxnet/models/syntaxnet# ls -l /root/.cache/bazel/_bazel_root/74c6bab7a21f28ad02405b720243d086/syntaxnet/_bin/namespace-sandbox
lrwxrwxrwx 1 root root 108 May 13 14:52 /root/.cache/bazel/_bazel_root/74c6bab7a21f28ad02405b720243d086/syntaxnet/_bin/namespace-sandbox -> /root/.cache/bazel/_bazel_root/install/ca381eaad1c931167a6355cb8a2b98cf/_embedded_binaries/namespace-sandbox
~/tensorflow_syntaxnet/models/syntaxnet# readlink /root/.cache/bazel/_bazel_root/74c6bab7a21f28ad02405b720243d086/syntaxnet/_bin/namespace-sandbox
/root/.cache/bazel/_bazel_root/install/ca381eaad1c931167a6355cb8a2b98cf/_embedded_binaries/namespace-sandbox
Command seems to work fine though:
~/tensorflow_syntaxnet/models/syntaxnet# file $(readlink /root/.cache/bazel/_bazel_root/74c6bab7a21f28ad02405b720243d086/syntaxnet/_bin/namespace-sandbox)
/root/.cache/bazel/_bazel_root/install/ca381eaad1c931167a6355cb8a2b98cf/_embedded_binaries/namespace-sandbox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[md5/uuid]=0xecfd97b6a6b9a193b045be13654bd55b, not stripped
~/tensorflow_syntaxnet/models/syntaxnet# /root/.cache/bazel/_bazel_root/install/ca381eaad1c931167a6355cb8a2b98cf/_embedded_binaries/namespace-sandbox
No command specified.
Usage: /root/.cache/bazel/_bazel_root/install/ca381eaad1c931167a6355cb8a2b98cf/_embedded_binaries/namespace-sandbox [-S sandbox-root] -- command arg1
provided: /root/.cache/bazel/_bazel_root/install/ca381eaad1c931167a6355cb8a2b98cf/_embedded_binaries/namespace-sandbox
Mandatory arguments:
-S <sandbox-root> directory which will become the root of the sandbox
-- command to run inside sandbox, followed by arguments
Optional arguments:
-W <working-dir> working directory
-T <timeout> timeout after which the child process will be terminated with SIGTERM
-t <timeout> in case timeout occurs, how long to wait before killing the child with SIGKILL
-d <dir> create an empty directory in the sandbox
-M/-m <source/target> system directory to mount inside the sandbox
Multiple directories can be specified and each of them will be mounted readonly.
The -M option specifies which directory to mount, the -m option specifies where to
mount it in the sandbox.
-n if set, a new network namespace will be created
-r if set, make the uid/gid be root, otherwise use nobody
-D if set, debug info will be printed
-l <file> redirect stdout to a file
-L <file> redirect stderr to a file
#FILE read newline-separated arguments from FILE
Any idea?
UPDATE: I have done exactly the same steps on a Ubuntu 14.04 LTS (my small workstation, as opposed to the production server running Debian) and everything works well there, with all tests passing. I wonder what's the difference.
Apparently some permission errors happens when setting up the sandbox. A quick workaround is to deactivate the sandbox by using --genrule_strategy=standalone --spawn_strategy=standalone (note that the second one is already specified in the TensorFlow rc file).
You can set those flag in your ~/.bazelrc:
echo "build --genrule_strategy=standalone --spawn_strategy=standalone" >>~/.bazelrc
I scp'd a Unix executable file into my work computer and am receiving an error when trying to run it. If I type in:
./cmpDNA 4 5 0.3 > results/results4_5_0.3.txt &
where cmpDNA is my program, 4 5 0.3 are input parameters and results/results4_5_0.3.txt is my output file, this is the error I receive:
-bash: ./cmpDNA: cannot execute binary file
I compiled in on my OS X computer using g++ and made sure to include my -m32 for a 32 bit build as the target computer is 32-bit Ubuntu. Typing:
file cmpDNA
gets:
cmpDNA: Mach-O executable i386
So I'm not sure why it won't execute. I've been looking for awhile but I can't find any answers that solve my problem. All users have executable permissions as well. Here were all of my compile options if that helps:
g++ -Wall -std=gnu++0x -o cmpDNA -m32 files.cpp
Thanks!
Can not compile on OS X without using a cross compiler and run on Ubuntu. Here is the answer that I found:
Compiling C Program on OS X to Run on Ubuntu
I have 32 bit C application(running on 64 bit system) leaking memory.
Do debug it I have downloaded valgrind 3.8.1 from http://valgrind.org/downloads/.
Did ./configure, make and make install to install valgrind.
But valgrind builds only 64 bit memcheck-amd64-linux binary.
32 bit memcheck is not getting built.
As a result I get below errors
# valgrind --tool=memcheck --time-stamp=yes -v --track-origins=yes --leak-check=yes /home/test_code32 --error-limit=no
valgrind: failed to start tool 'memcheck' for platform 'x86-linux': No such file or directory
Stracing valgrind gives me:
execve("/usr/local/lib/valgrind/memcheck-x86-linux", ["valgrind", "--tool=memcheck", "--time-stamp=yes", "-v", "--track-origins=yes", "--leak-check=yes", "/home/test_code32", "--error-limit=no"], [/* 60 vars */]) = -1 ENOENT (No such file or directory)
write(2, "valgrind: failed to start tool '"..., 94valgrind: failed to start tool 'memcheck' for platform 'x86-linux': No such file or directory
) = 94
I checked the ./configure output and it says:
checking for 32 bit build support... no
I am using gcc (SUSE Linux) 4.3.4.
Any idea how to get valgrind build 32 bit memcheck on 64 bit machine?
I have resolved the issue.
I installed 32-bit gcc support and then again built valgrind and it created the 32 bit memcheck.
I had the same issue, and resolved it by setting an environment variable:
export VALGRIND_LIB=/YourValgrindInstallDirectory/lib/valgrind
which is the direcory where valgrind missing lib is.
Try re-running your configure script with the --enable-only32bit option:
./configure --enable-only32bit
I installed the 32bit version of valgrind and it seems that it works now. The information about installing the 32bit version I took it from here