I'm trying using package manager nix for my C++ project.
default.nix:
{ pkgs ? import <nixpkgs> {} }:
let
stdenv = pkgs.stdenv;
in rec {
myProject = stdenv.mkDerivation {
name = "lynx";
version = "dev-0.4.0";
buildInputs = [
pkgs.cmake
pkgs.gtest
];
};
}
I built the project in its directory by using cmake without any problems. Then I exported the project as an Eclipse project (I did it under nix-shell):
cd ..
mkdir lynx_eclipse
cd lynx_eclipse
cmake -G"Eclipse CDT4 - Unix Makefiles" -D PLATFORM:STRING="posix" -DCMAKE_BUILD_TYPE=Debug ../lynx/
Having opened the exported project in Eclipse I found that include paths are fine and point to /nix/store/*. But when I try to build the project I have an error:
gtest/gtest.h: No such file or directory
I see that Eclipse doesn't add nix'es paths to the compiler flags:
/nix/store/ix03iknfgyrx7421fppjdczd9r4sw7pz-gcc-wrapper-5.3.0/bin/g++ -I/home/ubuntu-pc/dcs/lynx/inc -I/home/ubuntu-pc/dcs/lynx_eclipse/inc -I/home/ubuntu-pc/dcs/lynx/test/./inc -std=c++11 -static-libstdc++ -g -o CMakeFiles/test_utils.dir/utils_test.cpp.o -c /home/ubuntu-pc/dcs/lynx/test/utils_test.cpp
That could be reason of the problem but I don't know how to change Eclipse's behaviour.
Judging by the number of the views the problem is very specific. However, I found the solution somehow.
After the export to Eclipse project I made builder.sh file:
export NIX_PATH=nixpkgs=/home/xxxx/.nix-defexpr/channels/nixpkgs
/home/xxxx/.nix-profile/bin/nix-shell default.nix --run "make $1"
Then I set the file as a build command in C\C++ General -> C\C++ Make Project
bash ${project_loc}/build.sh
That's all.
Related
Is there any solution to make compilation with g++-8.2 for the project using Hazelcast C++ client library ?
If I compile it with g++-8.2, it shows a lot of errors "undefined reference ...".
While using g++-4.9, it works well.
The issue is a bit like the discussion in this google group forum, which indicated the compilation errors are because of the wrong version of a compiler.
However, the compiler g++-4.9 is too old for me to build my big project.
The sample code can be found in the official org website, if someone needs to give it a try.
I finally solved it by upgrading the library from 3.10 to 3.11.
The 3.11 library is built manually using g++-8.2 from Hazelcast source code in Github.
Because there is no make install after building hazelcast-cpp-clienet package, so I use some scripts to arrange header files together in one directory (hazelcast-cpp-client/include) so that a program can easily link the library and headers.
Build script:
#!/bin/bash
# Package Requirements:
# - asio
mkdir hazelcast-cpp-client ; cd hazelcast-cpp-client
# Build
git clone https://github.com/hazelcast/hazelcast-cpp-client.git
mv hazelcast-cpp-client tmp
cd tmp
git checkout v3.11
mkdir release ; cd release
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=Release ..
make
# Back to 'hazelcast-cpp-client' directory
cd ../..
# Copy .a library out from tmp/
cp tmp/release/*.a .
# Arrange all header files in an one directory
cp -r tmp/hazelcast/include .
cp -r tmp/hazelcast/generated-sources/include/hazelcast/client/protocol ./include/hazelcast/client
rm tmp/external/include/*.md # We don't need readme file
cp -r tmp/external/include/* ./include
# Delete tmp directory
rm -rf tmp
Compilation command is like:
g++ -std=c++11 \
-I/path/to/hazelcast-cpp-client/include \
hz_test.cpp \
/path/to/hazelcast-cpp-client/libHazelcastClient3.11_64.a \
-lpthread
Thanks for reporting this problem. We did not test with the g++-8.2 compiler. I opened an issue to solve the problems: https://github.com/hazelcast/hazelcast-cpp-client/issues/494
Can you tell me also your OS environment? What distribution and version is it?
I'm trying to build the latest clickhouse release (v1.1.54292-stable) in cygwin (mintty-2.7.9) on Windows server 2012 (build 9600).
I've picked and installed these additional packages in cygwin:
automake 10-1
automake 1.15.1-1
cmake 3.6.2.-1
gcc 6.3.0-2
g++ 6.3.0-2
gccmakedep 1.0.3.-1
git 2.14.1-2
libboost_system 1.63.0-1
libmcpp-devel 2.7.2-2
libmysqlclient-devel 10.1.26-1
libpcreposix0 8.40-3
libpoco-devel 1.7.9-1
libpoco-49 1.7.9-1
libtool 2.4.6-5
make 4.2.1-2
mcpp 2.7.2-2
poco 1.7.9-1
python3 3.6.1-1
I'm following the official instructions so I ran:
export THREADS=$(grep -c ^processor /proc/cpuinfo)
export CC=gcc
export CXX=g++
export CMAKE_LEGACY_CYGWIN_WIN32=1
mkdir build
cd build
cmake ..
make -j $THREADS
The compilation error I'm getting is this:
In function ‘CityHash_v1_0_2::uint128 CityHash_v1_0_2::CityMurmur(const char*, size_t, CityHash_v1_0_2::uint128)’:
/home/user/ClickHouse/contrib/libcityhash/src/city.cc:261:3:
error: ‘ssize_t’ was not declared in this scope
ssize_t l = len - 16;
If I grep the /usr/include/sys/types.h for ssize_t it's properly defined there, but for some reason the compiler can't find it.
Thanks for any advice...
From entire day I am trying to install OverSim [http://www.oversim.org/wiki/OverSimInstall]
The make file looks like this:
all: checkmakefiles
cd src && $(MAKE)
clean: checkmakefiles
cd src && $(MAKE) clean
cleanall: checkmakefiles
cd src && $(MAKE) MODE=release clean
cd src && $(MAKE) MODE=debug clean
rm -f src/Makefile
makefiles:
cd src && opp_makemake -f --deep --make-so -o inet -O out $$NSC_VERSION_DEF
checkmakefiles:
#if [ ! -f src/Makefile ]; then \
echo; \
echo '======================================================================='; \
echo 'src/Makefile does not exist. Please use "make makefiles" to generate it!'; \
echo '======================================================================='; \
echo; \
exit 1; \
fi
doxy:
doxygen doxy.cfg
tcptut:
cd doc/src/tcp && $(MAKE)
I am using Omnet5.1.1 as omnet4.2.2 is not supported on Ubuntu16.04, my gcc version is 5.4.1.
Every time I try to build this make all, it gives header file not found error where as in actual the header files are present inside the project directory.
In file included from applications/ethernet/EtherAppCli.cc:21:0:
applications/ethernet/EtherAppCli.h:21:22: fatal error: INETDefs.h: No such file or directory
The includes are done like this:
#include "INETDefs.h" //available at src/linklayer/contract/
#include "MACAddress.h" //available at src/base/
project structure:
How could I resolve this build error?
This is a basic difference between newer OMNeT++ versions 5.x and the older OMNeT++ versions 3.x and 4.x.
As far as I remember Oversim, it was released for build with OMNeT 3.x and 4.2 as well as the older INET releases.
These old versions used parameters like --deep to search for include files, that's why the included files are just named and not entered with a complete path.
The newer INET and OMNeT releases use hierarchical path settings for include files. The complete paths have to be given for the compiler to access the included file.
So for INET version 3.x and OMNeT++ version 5.x, an include looks like: #include "inet/common/INETDefs.h"
Oversim does not include the complete paths for included headers, that's why you have errors when using Oversim with newer OMNeT releases.
The first option is to either use an older OMNeT version. Either install an older GCC in parallel on your system or set-up a virtual machine with an older Ubuntu if you like.
The second (and more complex) option is to adopt all include paths or define all necessary paths via the -I option of the compiler/linker.
Frankly, I'd suggest to use the older OMNeT++ 4.2.2 version...
The #include directive searches first of all inside the same directory as the file containing the directive and then in a preconfigured list of standard system directories.
If you don't want to move the header files to the same directory as EtherAppCli.cc, you will have to add the paths to these header files to this preconfigured list, usually with the compiler option
-Ipath/to/dir
I'm not sure if this is what is intended in the app your'e compiling but this is more or less what you can do.
Check to see if you missed anything in the installation guide.
Use OMNet 4.6 instead. Keep using inet-20111118. You should be able to build inet normally. Then build Oversim
I'm getting "make: ***[diffusionWeightsTest] Error 1" and "recipe for target 'diffusionWeightsTest' failed" errors when trying to build a program in Eclipse's C++ IDE. If I open the makefile, the following code block is implicated with the error (specifically, the error is on #echo 'Building target: $#'):
diffusionWeightsTest: $(OBJS) $(USER_OBJS)
#echo 'Building target: $#'
#echo 'Invoking: GCC C++ Linker'
g++ -o "diffusionWeightsTest" $(OBJS) $(USER_OBJS) $(LIBS)
#echo 'Finished building target: $#'
#echo ' '
If I create a new HelloWorld C++ project and build it, it seems to work fine. Beyond linking the GSL libraries, I haven't done anything other than copy in my .C and .H code files (from my Windows machine, where I originally wrote them).
I'd like to do C++ development using Eclipse's IDE and the GSL library on a virtual Ubuntu Linux machine. I installed Oracle's JDK, the GSL library (following the INSTALL guidelines), and Eclipse's latest C++ IDE. In my program's properties, I linked the gsl and gslcblas libraries (right-click project name >> Properties >> C/C++ Build >> Settings >> GCC C++ Linker >> Libraries >> add both gslcblas and gsl to Libraries (-l) ) such that Eclipse seems to recognize those functions in the code.
Any ideas what might be causing this makefile error?
Just figured this out, actually. Apparently, there's a particular order in how you link the GSL libraries to your project. You have to list "gsl" first and then list "gslcblas".
So, to clarify, after you've installed the GSL library (download the package from their website, extracted it, opened the terminal inside the GSL folder, ./configure, make, sudo make install), you have to link the gsl and gslcblas libraries to your Eclipse project. Right-click the project name in the Project Explorer in Eclipse >> Properties >> C/C++ Build >> Settings >> GCC C++ Linker >> Libraries >> add both gsl and gslcblas to Libraries (-l).
But you must put gsl first and then gslcblas. The order matters. You'll get the errors above otherwise.
I have cygwin installed, and I want to use Eclipse with CDT for development under Windows 7. However, I get following error:
**** Build of configuration Default for project hello_cpp ****
make all
g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp
process_begin: CreateProcess(C:\cygwin\bin\g++.exe, g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp, ...) failed.
make (e=5): Access denied.
make: *** [hello_cpp.o] Error 5
**** Build Finished ****
I'm able to use g++ as standalone compiler.
cygwin /bin folder is
added to path.
After googling I found out that C:\cygwin\bin\g++.exe is a cygwin symbolic link and Windows doesn't understand it and I need to point to the g++-3 location directly. How do I do it?
I think you've done something wrong and need to start over again. Just installed Cygwin and Eclipse CDT (Indigo) on my Windows 7 and all works fine and auto-magicaly for me.
Here's what I did and I think you need to do:
Get the latest Cygwin (yes, get it again! get rid of the old one just to be sure)
During the installation make sure to select gcc, gcc-g++ and make (I additionally installed couple of other things like gcc4, w32api but it's optional)
Start Cygwin terminal to init all configuration files, etc. See if g++ executes and close the terminal.
Add C:\cygwin\bin (or wherever else you installed it) to your Environment PATH variable
Get Eclipse CDT, extract it somewhere and start it up.
Go to File -> New Project -> C++ Project and select Hello World C++ Project. You should see the Cygwin GCC in the Toolchains list.
Create the Project, build and run it!
Done!
Build output:
**** Build of configuration Debug for project TestApp ****
make all
Building file: ../src/TestApp.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestApp.d" -MT"src/TestApp.d" -o "src/TestApp.o" "../src/TestApp.cpp"
Finished building: ../src/TestApp.cpp
Building target: TestApp.exe
Invoking: Cygwin C++ Linker
g++ -o "TestApp.exe" ./src/TestApp.o
Finished building target: TestApp.exe
**** Build Finished ****
You can go to
Project Properties Page > C / C++ Build > Settings > Tool Settings
And change the command as you want. Documentation here.
Refer this link, it shows how to setup eclipse for native development with ease. everything is done in eclipse except setting environment variables.