Has anyone successfully compiled the performance test application for boost::math library?
link: http://www.boost.org/doc/libs/1_50_0/libs/math/doc/sf_and_dist/html/math_toolkit/perf/perf_test_app.html
I tried compiling by running b2 in the directory and there were lots of errors (over 222000 lines).
First few lines of errors:
../test/erf_data.ipp:6:74: error: wrong number of template arguments (1, should be 2)
In file included from ../../../boost/math/tools/rational.hpp:13:0,
from ../../../boost/math/special_functions/log1p.hpp:18,
from ../../../boost/math/special_functions/gamma.hpp:35,
from test_erf.cpp:9:
../../../boost/array.hpp:60:11: error: provided for ‘template<class T, long unsigned int N> class boost::array’
In file included from test_erf.cpp:13:0:
../test/erf_data.ipp:6:80: error: template argument 1 is invalid
../test/erf_data.ipp:6:91: error: invalid type in declaration before ‘=’ token
../test/erf_data.ipp:7:38: error: ‘SC_’ was not declared in this scope
../test/erf_data.ipp:7:88: error: ‘SC_’ was not declared in this scope
In file included from test_erf.cpp:13:0:
../test/erf_data.ipp:7:136: error: ‘SC_’ was not declared in this scope
Alright, I got it to compile and link properly but it was not with b2. I know the OP asked for b2 but im not familiar with it so i am providing an alternative. This solution assumes you have Cmake installed. (easy to do, just ask dr google.)
If you go to the math tests location:
~/pathToBoost/libs/math/performance
and you add a file called:
CMakeLists.txt
with the following Contents:
cmake_minimum_required(VERSION 2.8)
find_package(Boost COMPONENTS REQUIRED)
include_directories(${DEPENDENCY_DIR}/libboost/lib)
add_executable(main main.cpp test_reference.cpp)
target_link_libraries (main ${Boost_LIBRARIES} boost_regex)
Then you make a folder called build:
mkdir build
And build it.
cd build
cmake ..
make
Doing this got me successful compilation and building. I get a program called main out of it.
Hope this helps.
Related
I would like to use Open3d in LAMMPS. Open3D details how to find the pre-installed Open3D package using cmake.
Using the above, I have written a cmake file that I believe LAMMPS uses during its build stage to find packages and link them. Curiously, the line
target_link_libraries(lammps PRIVATE Open3D::Open3D)
appears to cause the compiler to find errors in the LAMMPS src code, i.e.,
/home/USER/lammps/src/fmtlib_format.cpp:58:51: error: duplicate explicit instantiation of ‘struct fmt::v7_lmp::detail::basic_data<void>’ [-fpermissive]
58 | template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
If I comment the target_link_libraries statement, the code compiles just fine (but doesn't link to Open3D). Apologies for being unable to provide a MWE as I do not know how to replicate this behaviour in a simple manner. Could you please explain to me why the target_link_libraries command causes the compiler to find errors in the LAMMPS src code and provide a solution to prevent this from occuring? If relevant I am using Clion 2021.1.2 and
CMAKE_CXX_COMPILER_VERSION = 9.3.0
CMAKE_CXX_STANDARD = 11
CMAKE_VERSION = 3.19.2
I want to use GnuplotHelper in ns3 to plot the results. even when I run ns3's default example seventh.cc I get the following error:
../scratch/congestion.cc: In function ‘int main(int, char**)’:
../scratch/congestion.cc:173:1: error: ‘GnuplotHelper’ was not declared in this scope
GnuplotHelper plotHelper;
^
../scratch/congestion.cc:180:1: error: ‘plotHelper’ was not declared in this scope
plotHelper.ConfigurePlot ("Test","CongestionWindow vs. Time","Time (Seconds)","CongestionWindow","jpg");
^
../scratch/congestion.cc:181:81: error: ‘GnuplotAggregator’ has not been declared
plotHelper.PlotProbe (probeName,probeTrace,"CongetionWindow","CongestionWindow",GnuplotAggregator::KEY_BELOW);
If I include "gnuplot-helper.h" I get an additional line and same error:
../scratch/seventh.cc:24:28: fatal error: gnuplot-helper.h: No such file or directory
compilation terminated.
I've installed gnuplot on my linux. What should I do? How can I declare Gnuplot helper?
First, did you install a gnu-plot-dev package or just gnuplot? Many distributions separate the ability to use libraries and the ability to develop against them.
If you are sure the include files are actually on your system somewhere (check both /usr/include and /usr/local/include/) you may need to add an additional directory level to your compiler search path (perhaps /usr/include/gnuplot/ but I am only guessing there).
Try
#include "ns3/stats-module.h"
CMake is giving me a real hard time, here. I checked out llvm, clang, and extras, and I created a custom driver folder, added it to the llvm\tools\clang\tools\extra\CMakeLists.txt and created my own CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
set(LLVM_LINK_COMPONENTS
Support
)
set(CMAKE_CXX_FLAGS ${LLVM_CONFIG})
set(CMAKE_CXX_COMPILER "clang++")
add_clang_executable(mydriver
main.cpp
)
set(CLANG_LIBS clangFrontend clangDriver clangSerialization clangParse
clangCodeGen clangSema clangAnalysis clangEdit clangAST clangLex
clangBasic )
target_link_libraries(mydriver ${CLANG_LIBS})
target_link_libraries(mydriver ${LLVM_LIBS})
CMake works fine. I target VS2017 and build the mydriver project with msbuild
λ msbuild tools\clang\tools\extra\mydriver\mydriver.vcxproj
This results in the following error:
"C:\dev\llvm-build\tools\clang\tools\extra\mydriver\mydriver.vcxproj" (default target) (1) ->
(ClCompile target) ->
C:\dev\llvm\tools\clang\tools\extra\mydriver\main.cpp(45): error C2027: use of undefined type 'clang::Preprocessor Options' [C:\dev\llvm-build\tools\clang\tools\extra\mydriver\mydriver.vcxproj]
C:\dev\llvm\tools\clang\tools\extra\mydriver\main.cpp(45): error C2228: left of '.addRemappedFile' must have class /struct/union [C:\dev\llvm-build\tools\clang\tools\extra\mydriver\mydriver.vcxproj]
C:\dev\llvm\tools\clang\tools\extra\mydriver\main.cpp(50): error C2664: 'void clang::CompilerInstance::setInvocati on(std::shared_ptr<clang::CompilerInvocation>)': cannot convert argument 1 from 'clang::CompilerInvocation *' to 'st d::shared_ptr<clang::CompilerInvocation>' [C:\dev\llvm-build\tools\clang\tools\extra\mydriver\mydriver.vcxproj]
However, clangLex is clearly included in the CLANG_LIBS variable in my CMakeLists.txt. The documentation of the clang::PreprocessorOptions class seems to indicate that I have the right libs included.
Any ideas?
Please note that this question is closely related to this one:
Generate assembly from C code in memory using libclang
In classic SO fashion, the problem was that the include file had migrated since the example was posted. The clang documentation requires a new header file, that is, in fact, in the include path. All I needed was:
#include <clang/Lex/PreprocessorOptions.h>
Sorry folks, nothing to see here.
I am attempting to compile cutecash (a qt project) and having a bit of trouble. I am just doing the standard:
cmake .
make
However, I am getting errors about not being able to find QMainWindow and QString among other things. Here is the error:
http://pastebin.com/GGHTXE4N
In file included from /home/username/code/gnucash/src/gnc/fpo/ViewletView.hpp:14:0,
from /home/username/code/gnucash/src/gnc/fpo/FPO.hpp:4,
from /home/username/code/gnucash/src/gnc/fpo/moc_FPO.cxx:9:
/home/username/code/gnucash/src/gnc/mainwindow.hpp:26:23: fatal error: QMainWindow: No such file or directory
compilation terminated.
/home/username/code/gnucash/src/gnc/moc_RecentFileMenu.cxx:15:2: error: #error "This file was generated using the moc from 5.0.1. It"
/home/username/code/gnucash/src/gnc/moc_RecentFileMenu.cxx:16:2: error: #error "cannot be used with the include files from this version of Qt."
/home/username/code/gnucash/src/gnc/moc_RecentFileMenu.cxx:17:2: error: #error "(The moc has changed too much.)"
In file included from /home/username/code/gnucash/src/gnc/AccountItemModel.hpp:28:0,
from /home/username/code/gnucash/src/gnc/dashboard.hpp:34,
from /home/username/code/gnucash/src/gnc/moc_dashboard.cxx:9:
/home/username/code/gnucash/src/gnc/QofEventWrapper.hpp:37:19: fatal error: QString: No such file or directory
compilation terminated.
In file included from /home/username/code/gnucash/src/gnc/SplitListModel.hpp:29:0,
from /home/username/code/gnucash/src/gnc/moc_SplitListModel.cxx:9:
/home/username/code/gnucash/src/gnc/QofEventWrapper.hpp:37:19: fatal error: QString: No such file or directory
compilation terminated.
Something that seems fairly significant:
error: #error "This file was generated using the moc from 5.0.1. It"
error: #error "cannot be used with the include files from this version of Qt."
error: #error "(The moc has changed too much.)"
So whenever I attempt to install qt5-default (on ubuntu) I must remove qt4-default. If I attempt to compile now, I get the same issues with being unable to fin QMainWindow and a few other pieces (such as QAbstractItemDelegate).
I also receive this warning:
#error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC or -fPIE."
Along with a few new errors which seem like they happen due to being unable to find items. I am on ubuntu 13.04.
Steps that work for me:
svn checkout http://svn.gnucash.org/repo/gnucash/trunk
mkdir -p trunk/build
cd trunk/build
cmake ..
make
I am trying to use QTPropertyBrowser to edit properties in my QObjects.
From QT Solutions "QtPropertyBrowser" example I use following files in my project.
http://qt.gitorious.org/qt-solutions/qt-solutions/blobs/master/qtpropertybrowser/examples/object_controller/objectcontroller.cpp
http://qt.gitorious.org/qt-solutions/qt-solutions/blobs/master/qtpropertybrowser/examples/object_controller/objectcontroller.h
I configure my CMakeFile as follows :
#include_directories("/usr/include")
SET(QTVIEW_SRCS
src/main.cpp
src/TestWidget.cpp
src/plugin/IPlugin.cpp
src/objectcontroller.cpp
)
SET(QTVIEW_MOH_HDRS
src/TestWidget.h
src/plugin/IPlugin.h
src/objectcontroller.h
)
When I compile the files as they are, compiler giving error as follows -
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:
In member function 'virtual int
ObjectController::qt_metacall(QMetaObject::Call,
int, void**)' :
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:73:
error: invalid use of incomplete type
'struct ObjectControllerPrivate'
C:\svn\osaka3d\trunk\osaka3d\QTView\src/objectcontroller.h:45:
error: forward declaration of 'struct
ObjectControllerPrivate'
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:73:
error: expected type-specifier before
'QtProperty'
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:73:
error: expected '>' before
'QtProperty'
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:73:
error: expected '(' before
'QtProperty'
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:73:
error: 'QtProperty' was not declared
in this scope
C:\svn\osaka3d\trunk\osaka3d\QTView\src\moc_objectcontroller.cxx:73:
error: expected primary-expression
before ')' token mingw32-make2: *
[CMakeFiles/qtview.dir/src/moc_objectcontroller.cxx.obj]
Error 1 mingw32-make1:
[CMakeFiles/qtview.dir/all] Error 2
mingw32-make: ** [all] Error 2
But when I comment out the line :
Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QVariant &))
in "objectcontroller.h"
and comment out the line :
#include "moc_objectcontroller.cxx"
and the end of file "objectcontroller.cpp" , it compiles well But i cannot use SIGNALS/SLOTs to reflect editing of QObject parameters.
Any tips?
I ran into the same problem (I am new to qt, but this worked for me). For other people searching a solution I found this:
What is happening
The issue is that due to Q_PRIVATE_SLOT macro the generated moc_XXX.cxx needs the full declaration of the XXXPrivate class to call the private slot function. As the public header only forward declares it, the generated cxx can not be compiled on its own. The QtPropertyBrowser guys circumvented this problem by including the generated moc_XXX.cpp (mind the 'pp', cmake generates 'xx')) in their source file (ugly, but works). I also do not know any other way to tell the moc to include (the in this case even not present) private XXX_p.hpp. So let's stick to that way.
What I did next was to remove the generated moc_XXX.cxx files from the executable, but this resulted in the moc never being called. This happened even though I used QT4_WRAP_CPP. So after further searching I found...
One addendum to this special case: the QtProperty declaration is missing. Either add the following forward declaration or the appropriate include file:
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class QtProperty;
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
Solution
Full credit goes to fullmetalcoder who presented this cmake function:
function(qt4_wrap_hdrs _moc_srcs)
qt4_get_moc_flags(_moc_incs)
set(_mocs)
foreach(_current_file ${ARGN})
get_filename_component(_abs_file ${_current_file} ABSOLUTE)
if(EXISTS ${_abs_file})
file(READ ${_abs_file} _contents)
get_filename_component(_basename ${_abs_file} NAME_WE)
string(REGEX MATCH "Q_OBJECT" _match "${_contents}")
if(_match)
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp")
qt4_create_moc_command(${_abs_file} ${_moc} "${_moc_incs}" "")
macro_add_file_dependencies(${_abs_file} ${_moc})
list(APPEND _mocs ${_moc})
endif(_match)
endif(EXISTS ${_abs_file})
endforeach (_current_file)
set(${_moc_srcs} ${_mocs} PARENT_SCOPE)
endfunction(qt4_wrap_hdrs)
(from http://www.qtcentre.org/threads/37428-using-QT-unit-testing-with-CMake)
You can use this function as a drop-in replacement for QT4_WRAP_CPP. You now only need to add the following line into your CMakeLists.txt so that the compiler finds the generated moc_XXX.cpp files (the new function created a 'pp' file...):
include_directories(${CMAKE_BINARY_DIR})
This function calls the moc all the time and behaves more like as in the qmake case. Except of course that you can easily do out of source builds.
But there is one caveat: all moc_XXX.cpp files are generated in the CMAKE_BINARY_DIR. So if you have two files include1/foo.hpp and include2/foo.hpp one will be overwritten!
Have you read the following article about using Qt and CMake together?
http://developer.qt.nokia.com/quarterly/view/using_cmake_to_build_qt_projects
Maybe you're forgetting something, like calling QT4_WRAP_CPP on your CMakeLists.txt.