So I installed wiringPi onto my Raspberry Pi, I used the "./build" to make and install. I then didn't have the .h files in any of the include directories ("/usr/local/include" as an example) so I copied all of them into both "/usr/include" and into "/usr/local/include".
So I have been compiling for the Raspberry Pi already but when trying to do it with wiringPi I just get the Make *** [] Error 1.
After following what others instructed I ammended the command Eclipse uses
Cross G++ Compiler (Miscellanious):
-c -fmessage-length=0 -pthread -std=c++11 -Wl,--no-as-needed -lwiringPi -lwiringPiDev
Cross G++ Linker (Miscellanious):
-pthread -std=c++11 -Wl,--no-as-needed -lwiringPi -lwiringPiDev
In my "Include Paths (-l)" I have "/home/gummielovingmudkip/.local/share/raspberrypi/rootfs/usr/local/include"
Here is my main.cpp file
#include <iostream>
#include <fstream>
#include <ctime>
#include <stdlib.h>
extern "C" {
#include <wiringPi.h>
}
#include "Logging.hpp"
int main() {
// Loading all necessary classes
Logging log;
// Beginning
log.setup("susie");
log.print(1, "main() has started");
log.print(1, "All classes have been loaded");
// Setting up wiringPi
wiringPiSetup () ;
// Setting pin modes
pinMode (0, OUTPUT) ;
for (;;) {
digitalWrite (0, HIGH) ; delay (500) ;
digitalWrite (0, LOW) ; delay (500) ;
}
return 0;
}
The above code gives no errors, I just get the compiler error.
I thank you all in advance.
Edit:
Sorry for not including the error message!
make: *** [Logging.o] Error 1
Related
I could not include (could not compile to be exact) fmt/format with GCC-12.
file 1: format
#pragma once
#define FMT_HEADER_ONLY
#include "fmt/format.h"
namespace std
{
using fmt::format;
using fmt::format_error;
using fmt::formatter;
}
file 2: helloworld.cpp
// helloworld.cpp
import <iostream>;
#include "format"
int main()
{
std::cout << std::format("There are {} ways I love you.", 219) << std::endl;
return 0;
}
Commands:
g++-12 -std=c++2a -fmodules-ts -xc++-system-header iostream
g++-12 -std=c++2a -fmodules-ts helloworld.cpp
Error message:
fmt/format.h:1010:54: internal compiler error: in cxx_eval_call_expression, at cp/constexpr.cc:2835
1010 | return {result.grouping, Char(result.thousands_sep)};
| ^
OS - WSL2/Ubuntu 22.04 LTS
fmt - fmt-8.1.1
Any help is appreciated. Thank you.
I am currently trying to use the DLFCN-WIN32 library in order to use a c++ script originally implemented to use the dlfcn.h library.
When compiling the code (cantera V2.3), everything goes well except when generating the shared library where the dlopen and dlclose functions are not found.
originally script is :
/**
* #file CustomKinetics.cpp
*
* #ingroup chemkinetics
*/
//
// Author: Q. Cazeres, A. Felden, P. Pepiot
//
//
#include "cantera/kinetics/CustomKinetics.h"
#include <iostream>
#include <dlfcn.h>
using namespace std;
namespace Cantera
{
CustomKinetics::CustomKinetics(thermo_t* th) : GasKinetics(th)
{
printf("WARNING: Using customized kinetics from f90 file.\n");
handle = dlopen("customkinetics.so", RTLD_LAZY);
// load symbol
ck = (ck_t) dlsym(handle, "customkinetics_");
}
void CustomKinetics::get_wdot_reduced(doublereal* wdot)
{
doublereal P = thermo().pressure();
doublereal T = thermo().temperature();
// New yarc2 format
//doublereal rho = thermo().density();
const doublereal* m_y = thermo().massFractions();
ck(&P,&T,&m_y[0],&wdot[0]);
// New yarc2 format
//ck(&P,&T,&rho,&m_y[0],&wdot[0]);
// Old yarc format
//mol/kmol conversion cantera is in kmol
for (size_t i=0;i<thermo().nSpecies();i++) {
wdot[i]=wdot[i]/1000.0;
}
}
The script is compiled with the following command line :
g++ -o build\src\kinetics\CustomKinetics.o -c -std=c++0x -lpsapi -O3 -Wno-inline -g -Wall -include src/pch/system.h -DNDEBUG -Iinclude -Iinclude\cantera\ext -Ibuild\src -Ibuild\src\L -Isrc\L -IL:\LIB_WINDOWS\DLFCN-WIN32\include -IL:\LIB_WINDOWS\BOOST\boost_1_78_0 src\kinetics\CustomKinetics.cpp
The shared library is compiled with the following command line :
scons: warning: Using $CXX to link Fortran and C++ code together.
This may generate a buggy executable if the 'g++'
compiler does not know how to deal with Fortran runtimes.
g++ -static-libgcc -static-libstdc++ -shared -o build\lib\cantera_shared.dll build\ext\libexecstream\exec-stream.o build\ext\fmt\fmt\format.o build\ext\fmt\fmt\ostream.o build\ext\fmt\fmt\posix.o build\ext\sundials\src\sundials\sundials_band.o build\ext\sundials\src\sundials\sundials_dense.o build\ext\sundials\src\sundials\sundials_direct.o build\ext\sundials\src\sundials\sundials_iterative.o build\ext\sundials\src\sundials\sundials_math.o build\ext\sundials\src\sundials\sundials_nvector.o build\ext\sundials\src\sundials\sundials_pcg.o build\ext\sundials\src\sundials\sundials_sparse.o build\ext\sundials\src\sundials\sundials_spbcgs.o build\ext\sundials\src\sundials\sundials_spfgmr.o build\ext\sundials\src\sundials\sundials_spgmr.o build\ext\sundials\src\sundials\sundials_sptfqmr.o build\ext\sundials\src\nvec_ser\fnvector_serial.o build\ext\sundials\src\nvec_ser\nvector_serial.o build\ext\sundials\src\cvodes\cvodea.o build\ext\sundials\src\cvodes\cvodea_io.o build\ext\sundials\src\cvodes\cvodes.o build\ext\sundials\src\cvodes\cvodes_band.o build\ext\sundials\src\cvodes\cvodes_bandpre.o build\ext\sundials\src\cvodes\cvodes_bbdpre.o build\ext\sundials\src\cvodes\cvodes_dense.o build\ext\sundials\src\cvodes\cvodes_diag.o build\ext\sundials\src\cvodes\cvodes_direct.o build\ext\sundials\src\cvodes\cvodes_io.o build\ext\sundials\src\cvodes\cvodes_sparse.o build\ext\sundials\src\cvodes\cvodes_spbcgs.o build\ext\sundials\src\cvodes\cvodes_spgmr.o build\ext\sundials\src\cvodes\cvodes_spils.o build\ext\sundials\src\cvodes\cvodes_sptfqmr.o build\ext\sundials\src\ida\ida.o build\ext\sundials\src\ida\ida_band.o build\ext\sundials\src\ida\ida_bbdpre.o build\ext\sundials\src\ida\ida_dense.o build\ext\sundials\src\ida\ida_direct.o build\ext\sundials\src\ida\ida_ic.o build\ext\sundials\src\ida\ida_io.o build\ext\sundials\src\ida\ida_sparse.o build\ext\sundials\src\ida\ida_spbcgs.o build\ext\sundials\src\ida\ida_spgmr.o build\ext\sundials\src\ida\ida_spils.o build\ext\sundials\src\ida\ida_sptfqmr.o build\src\base\Parser.o build\src\base\ValueCache.o build\src\base\application.o build\src\base\checkFinite.o build\src\base\clockWC.o build\src\base\ct2ctml.o build\src\base\ctexceptions.o build\src\base\ctml.o build\src\base\global.o build\src\base\plots.o build\src\base\stringUtils.o build\src\base\xml.o build\src\thermo\ConstCpPoly.o build\src\thermo\ConstDensityThermo.o build\src\thermo\DebyeHuckel.o build\src\thermo\Elements.o build\src\thermo\FixedChemPotSSTP.o build\src\thermo\GibbsExcessVPSSTP.o build\src\thermo\HMWSoln.o build\src\thermo\HMWSoln_input.o build\src\thermo\IdealGasPhase.o build\src\thermo\IdealMolalSoln.o build\src\thermo\IdealSolidSolnPhase.o build\src\thermo\IdealSolnGasVPSS.o build\src\thermo\IonsFromNeutralVPSSTP.o build\src\thermo\LatticePhase.o build\src\thermo\LatticeSolidPhase.o build\src\thermo\MargulesVPSSTP.o build\src\thermo\MaskellSolidSolnPhase.o build\src\thermo\MetalSHEelectrons.o build\src\thermo\MineralEQ3.o build\src\thermo\MixedSolventElectrolyte.o build\src\thermo\MixtureFugacityTP.o build\src\thermo\MolalityVPSSTP.o build\src\thermo\MolarityIonicVPSSTP.o build\src\thermo\Mu0Poly.o build\src\thermo\MultiSpeciesThermo.o build\src\thermo\Nasa9Poly1.o build\src\thermo\Nasa9PolyMultiTempRegion.o build\src\thermo\NasaPoly2.o build\src\thermo\PDSS.o build\src\thermo\PDSS_ConstVol.o build\src\thermo\PDSS_HKFT.o build\src\thermo\PDSS_IdealGas.o build\src\thermo\PDSS_IonsFromNeutral.o build\src\thermo\PDSS_SSVol.o build\src\thermo\PDSS_Water.o build\src\thermo\Phase.o build\src\thermo\PhaseCombo_Interaction.o build\src\thermo\PureFluidPhase.o build\src\thermo\RedlichKisterVPSSTP.o build\src\thermo\RedlichKwongMFTP.o build\src\thermo\SemiconductorPhase.o build\src\thermo\SingleSpeciesTP.o build\src\thermo\Species.o build\src\thermo\SpeciesThermoFactory.o build\src\thermo\SpeciesThermoInterpType.o build\src\thermo\StoichSubstance.o build\src\thermo\SurfPhase.o build\src\thermo\ThermoFactory.o build\src\thermo\ThermoPhase.o build\src\thermo\VPSSMgr.o build\src\thermo\VPSSMgrFactory.o build\src\thermo\VPSSMgr_ConstVol.o build\src\thermo\VPSSMgr_General.o build\src\thermo\VPSSMgr_IdealGas.o build\src\thermo\VPSSMgr_Water_ConstVol.o build\src\thermo\VPSSMgr_Water_HKFT.o build\src\thermo\VPStandardStateTP.o build\src\thermo\WaterProps.o build\src\thermo\WaterPropsIAPWS.o build\src\thermo\WaterPropsIAPWSphi.o build\src\thermo\WaterSSTP.o build\src\tpx\CarbonDioxide.o build\src\tpx\HFC134a.o build\src\tpx\Heptane.o build\src\tpx\Hydrogen.o build\src\tpx\Methane.o build\src\tpx\Nitrogen.o build\src\tpx\Oxygen.o build\src\tpx\RedlichKwong.o build\src\tpx\Sub.o build\src\tpx\Water.o build\src\tpx\lk.o build\src\tpx\utils.o build\src\equil\BasisOptimize.o build\src\equil\ChemEquil.o build\src\equil\MultiPhase.o build\src\equil\MultiPhaseEquil.o build\src\equil\vcs_Gibbs.o build\src\equil\vcs_MultiPhaseEquil.o build\src\equil\vcs_SpeciesProperties.o build\src\equil\vcs_TP.o build\src\equil\vcs_VolPhase.o build\src\equil\vcs_elem.o build\src\equil\vcs_elem_rearrange.o build\src\equil\vcs_inest.o build\src\equil\vcs_nondim.o build\src\equil\vcs_phaseStability.o build\src\equil\vcs_prep.o build\src\equil\vcs_prob.o build\src\equil\vcs_rearrange.o build\src\equil\vcs_report.o build\src\equil\vcs_rxnadj.o build\src\equil\vcs_setMolesLinProg.o build\src\equil\vcs_solve.o build\src\equil\vcs_solve_TP.o build\src\equil\vcs_solve_phaseStability.o build\src\equil\vcs_species_thermo.o build\src\equil\vcs_util.o build\src\numerics\BandMatrix.o build\src\numerics\CVodesIntegrator.o build\src\numerics\DAE_solvers.o build\src\numerics\DenseMatrix.o build\src\numerics\Func1.o build\src\numerics\FuncEval.o build\src\numerics\IDA_Solver.o build\src\numerics\ODE_integrators.o build\src\numerics\ResidJacEval.o build\src\numerics\RootFind.o build\src\numerics\SquareMatrix.o build\src\numerics\funcs.o build\src\numerics\polyfit.o build\src\kinetics\AqueousKinetics.o build\src\kinetics\BulkKinetics.o build\src\kinetics\C12H26_25_373_27_TJKinetics.o build\src\kinetics\C12H26_NOX_27_452_20_TJKinetics.o build\src\kinetics\C2H4_18_320_11_AFKinetics.o build\src\kinetics\C3H8_22_173_12_FCKinetics.o build\src\kinetics\C7H16_25_210_27_FCKinetics.o build\src\kinetics\CH4_22_320_18_TJKinetics.o build\src\kinetics\CustomKinetics.o build\src\kinetics\Falloff.o build\src\kinetics\FalloffFactory.o build\src\kinetics\GasKinetics.o build\src\kinetics\Group.o build\src\kinetics\HYCHEM_27_272_12_AFKinetics.o build\src\kinetics\HYCHEM_NOX_29_548_17_AFKinetics.o build\src\kinetics\ImplicitSurfChem.o build\src\kinetics\InterfaceKinetics.o build\src\kinetics\Kinetics.o build\src\kinetics\KineticsFactory.o build\src\kinetics\Reaction.o build\src\kinetics\ReactionPath.o build\src\kinetics\RxnRates.o build\src\kinetics\importKinetics.o build\src\kinetics\solveSP.o build\src\kinetics\c12h262537327tj.o build\src\kinetics\c12h262745220tj.o build\src\kinetics\c2h41832011af.o build\src\kinetics\c3h82217312fc.o build\src\kinetics\c7h162521027fc.o build\src\kinetics\ch42232018tj.o build\src\kinetics\hychem2727212af.o build\src\kinetics\hychemnox2954817af.o build\src\kinetics\sankaran13.o build\src\transport\AVBPTransport.o build\src\transport\DustyGasTransport.o build\src\transport\GasTransport.o build\src\transport\HighPressureGasTransport.o build\src\transport\LTPspecies.o build\src\transport\LiquidTranInteraction.o build\src\transport\LiquidTransport.o build\src\transport\LiquidTransportData.o build\src\transport\LiquidTransportParams.o build\src\transport\MMCollisionInt.o build\src\transport\MixTransport.o build\src\transport\MultiTransport.o build\src\transport\SimpleTransport.o build\src\transport\SolidTransport.o build\src\transport\SolidTransportData.o build\src\transport\TransportBase.o build\src\transport\TransportData.o build\src\transport\TransportFactory.o build\src\transport\TransportParams.o build\src\transport\WaterTransport.o build\src\oneD\Domain1D.o build\src\oneD\MultiJac.o build\src\oneD\MultiNewton.o build\src\oneD\OneDim.o build\src\oneD\Sim1D.o build\src\oneD\StFlow.o build\src\oneD\boundaries1D.o build\src\oneD\refine.o build\src\zeroD\ConstPressureReactor.o build\src\zeroD\FlowDevice.o build\src\zeroD\FlowReactor.o build\src\zeroD\IdealGasConstPressureReactor.o build\src\zeroD\IdealGasReactor.o build\src\zeroD\Reactor.o build\src\zeroD\ReactorBase.o build\src\zeroD\ReactorFactory.o build\src\zeroD\ReactorNet.o build\src\zeroD\ReactorSurface.o build\src\zeroD\Wall.o build\src\clib\ct.o build\src\clib\ctfunc.o build\src\clib\ctmultiphase.o build\src\clib\ctonedim.o build\src\clib\ctreactor.o build\src\clib\ctrpath.o build\src\clib\ctsurf.o build\src\clib\ctxml.o -Lbuild\lib -Lbuild\src\L -Lsrc\L -LL:\LIB_WINDOWS\DLFCN-WIN32\lib -Wl,--out-implib,build\lib\libcantera_shared.a -Wl,--output-def,build\lib\cantera_shared.def
And after that I got the following error message :
=====
b"build\\src\\kinetics\\CustomKinetics.o: In function `Cantera::CustomKinetics::CustomKinetics(Cantera::ThermoPhase*)':\r\nL:\\LIB_WINDOWS\\CANTERA\\cantera-avbp-2.3/src/kinetics/CustomKinetics.cpp:23: undefined reference to `dlopen'\r\nL:\\LIB_WINDOWS\\CANTERA\\cantera-avbp-2.3/src/kinetics/CustomKinetics.cpp:26: undefined reference to `dlsym'\r\nbuild\\src\\kinetics\\CustomKinetics.o: In function `Cantera::CustomKinetics::close_dl()':\r\nL:\\LIB_WINDOWS\\CANTERA\\cantera-avbp-2.3/src/kinetics/CustomKinetics.cpp:53: undefined reference to `dlclose'\r\nL:\\LIB_WINDOWS\\CANTERA\\cantera-avbp-2.3/src/kinetics/CustomKinetics.cpp:53: undefined reference to `dlclose'\r\ncollect2.exe: error: ld returned 1 exit status\r\n"
=====
scons: *** [build\lib\cantera_shared.dll] Error 1
scons: building terminated because of errors.
The include and lib directories of the DLFCN-WIN32 libraries are well put in argument with -L option. Did I forget a compilation option?
Thank you in advance for your help,
Rock
I installed LLVM on a clear Windows 10 machine, without anything else. I installed the ARMCompiler6.14.1. I have a simple cpp for testing:
#include <stdio.h>
#include <iostream>
#include <vector>
int main(void) {
int counter = 0;
counter++;
printf("counter: %d", counter);
std::cout << std::endl;
printf("c++14 output");
std::cout << std::endl;
std::vector<int> vect{1, 2, 3, 4, 5};
for (auto & el : vect)
std::cout << "-" << el << std::endl;
return counter;
}
When I compile this with following line I get errors:
"C:\Program Files\LLVM\bin\clang++.exe" -MD -x c++ "C:\Test\test.cpp" -target armv7a-none-eabi "-IC:\Program Files\ARMCompiler.6.14.1\include"
The error is:
test.cpp 2:10:fatal error: 'iostream' file not found
When I compile this with following line I get an windows executable which runs:
"C:\Program Files\LLVM\bin\clang++.exe" -MD -x c++ "C:\Test\test.cpp"
Since I checked that in the LLVM\bin is anything from the developer.arm.com package (ARMcompiler 6.14.1), I think that I should get an a.out for ARM, but I do not. When I checked the generated object file with:
"C:\Program Files\LLVM\bin\llvm-objdump.exe" -f test.o
I get following:
test.o file format elf32-littlearm
arhitecture: arm
start adress: 0x00000000
which means the object file is correctly generated for ARM, but I did not get an executable a.out for ARM.
What am I missing? How should I compile a simple test program to get it cross-compiled for ARM? Should I get the binutil from GCC for the Clang to create ARM executables?
Set up MinGW and Netbeans. Only working withe othere IDE's and compilers in before. My machine is x64 win7x64. I'm not shure if I only installed the 32bit version of MinGW.
Compiling a simpel Helle World in x64 leeds to:
g++ -m64 -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d"
-o build/Debug/MinGW-Windows/main.o main.cpp
//Message: sorry, unimplemented: 64-bit mode not compiled in
The win32 Version compiles fine.
// ---
g++ -m32 -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d"
-o build/Debug/MinGW-Windows/main.o main.cpp
// Compiles without any error...
Starting the 32-Version it prints only one message and terminats withe a segmentation fault before returning from first std:cout. Using ftream, to make a file output same error occures.
The demo-Programm of netbeans "Welcome" throws the same exceptions.
#include <cstdlib>
#include <iostream> // EDIT! (worked at this post long time sry.)
using namespace std;
int main(int argc, char** argv) {
int i = 0; // for making shure, program is working before calling fs.open
std::cout << "hello world blubb" << endl; // this one shows up its message at consol.
//programm aborded.
std::cout << "Now again" << endl; // this on is never reached.
return 0;
}
Errormessages:
Signal received: SIGSEGV ( Segmentation fault )
For programm cppapplication_1 pid 7972
You may discard...
Errormessage windows:
cppapplication_1.exe does not work.
Where can I start my serach? Compiler? some dlls? Dependency Walker?
Thx for any comment =).
Cutton
Could someone help me with linking to a shared lib, specifically libzmq, in C++?
all: clean compile
clean:
rm bin *.o -f
compile:
g++ -g -Wall -I/usr/local/include -L/usr/local/lib main.cpp -lzmq -o bin
I've installed libzmq using the following steps:
git clone https://github.com/zeromq/libzmq.git
cd libzmq
./autogen.sh
./configure
make && sudo make install
Here's my main.cpp
#include <iostream>
#include <string>
#include <zmq/zmq.h>
// Required by fork routine
#include <sys/types.h>
#include <unistd.h>
// Required by wait routine
#include <sys/wait.h>
#include <stdlib.h> // Declaration for exit()
#include <cstdio> // printf
using namespace std;
int global_variable = 2;
int main(int argc, char** argv){
const short int FORK_FAILED = -1;
const short int FORK_SUCCESS = 0;
int stack_variable = 20;
pid_t pid;
string status_identifier;
switch (pid = fork()){
case FORK_SUCCESS:
printf("Child changing global and stack variables\n");
global_variable++;
stack_variable++;
break;
case FORK_FAILED:
cerr << "Failed! -- Failed to fork: " << pid << endl;
exit(1);
default:
printf("Child process (pid=%d) created successfully.\n", pid);
wait(0);
break;
}
printf("[pid=%d] Global: %d\n", pid, global_variable);
printf("[pid=%d] Stack: %d\n", pid, stack_variable);
return 0;
}
And, here's the error msg:
bitcycle # ubuntu64vm ~/git/test $ make
rm bin *.o -f
g++ -g -Wall -I/usr/local/include -L/usr/local/lib main.cpp -lzmq -o bin
main.cpp:4:23: fatal error: zmq/zmq.hpp: No such file or directory
compilation terminated.
make: *** [compile] Error 1
The error is pretty straight forward, but I've yet to find a solution. Any ideas?
My goal is to do something like this with multiple child processes.
Update I'm just going to install it system-wide in ubuntu: sudo apt-get install libzmq-dev, and that resolved the issue. It doesn't teach me anything about how to identify a shared lib and header file on disk and link to it... but I guess I can move that to another day.
C++ wrapper for ZeroMQ (zmq.hpp) is no longer part of ZeroMQ. There is no zmq.hpp in current libzmq master or in latest stable 3.2.x.