A simple scons example, I need guidance - scons

I created a simple hierarchial C++ project to help me learn the use of scons as I want to get away from cmake and qmake. I have registered it in a github repository at https://github.com/pleopard777/SConsEx . This project is organized into two primary subdirs; packages contains two libraries and testing contains two apps. The packages dir needs to be built first and when complete the testing dir needs to be built. Under the packages library the core library must be compiled first and the numerics library second. The numerics library depends on the core library. Under the testing dir the core_tests app depends on the core library and the numerics_tests app depends on core and numerics.
I am struggling with what seems to be limited documentation and examples for scons so I am posting this here in search of some guidance. Here are some of the initial problems I am having, any guidance will be greatly appreciated:
1) [Edit/FIXED]
2) In the packages/numerics/ dir the source files depend on the core library. The file numerics_config.h requires the file ../core/core_config.h however when building that core file cannot be found. The following SConstruct lines don't help:
[code]
include = '../../packages'
env = Environment(CPPPATH=include)
[/code]
Again, this is just a start to the project and I am using it to learn scons. Any guidance will be appreciated ... I'm sure I will be asking lots more questions as this project progresses.
Thanks!
P

Fixed in pull request to your repo.
Note you had some c++ issues as well. I've fixed them too.
See:
https://github.com/pleopard777/SConsEx/pull/1
(Please don't delete your repo so others can find the solution as well)

Related

How to install the "FastAD" C++ library in Rcpp?

I am trying to install a C++ library called FastAD ( https://github.com/JamesYang007/FastAD#user-guide) in Rcpp but the installation instructions are generic (not specifically for Rcpp).
It would be greatly appreciated if someone coule give me some guidance for how to install and be able to #include the files?
FastAD is a header-only library which only depends on Eigen3. That makes for a pretty straightforward application for Rcpp and friends.
First, rely on the RcppEigen.package.skeleton() function to create the barebones RcppEigen-using package.
Second, we copy the FastAD library into inst/include. We add a PKG_CPPFLAGS variable in src/Makevars to let R know to source it from there. That is all the compiler needs with a header-only library. (Edit: We also set CXX_STD=CXX17 unless one has a new enough compiler or R (currently: r-devel) which already default to C++17.)
Third, we create a simple example in src/ based on an example in FastAD. We picked the Black-Scholes example.
Fourth, minor cleanups like removing the hello* stanza files.
That is pretty much it. In its embryonic form the package is now here on GitHub. An example is
> library(RcppFastAD)
> blackScholesExamples()
56.5136
0.773818
51.4109
-0.226182
>

Compiling STK (Synthesis Toolkit) for use in Code::Blocks

I realise this is a newb question but I've been racking my brains for hours.
So I want to use the STK (Synthesis Toolkit) to generate sine waves etc. I've downloaded the source files from https://ccrma.stanford.edu/software/stk/download.html
I unzipped the tar.gz using 7zip.
I opened up the demo.cpp project file (under /projects/demo/demo.cpp) and whenever I try to compile it, I receive lots of errors, all starting with "undefined reference to"
I have set the compiler search directory to include the root folder of the stk kit (unzipped as "stk-4.5.0"). My understanding is that I also have to find file for the linker, that is of the type .lib? Is that correct? I haven't been able to find a .lib file to link to.
I feel like this is a simple fix - what am I missing?
You've downloaded a source , not the compiled library which might be used by linker (.lib file) There are three solutions:
1. Compile whole src folder of your download ( see instructions on their website). Frankly, I've tried to do that recently but failed, especially under Windows although I don't have any experience in this so you can try yourself.
2. Use precompiled library available in some Linux repositories. I had success with Slacko Puppy linux. Package simply adds libstk.a (linux static library) to /usr/lib and stk headers to /usr/include/stk (notice you have to add exactly that path to compiler, since /usr/lib is not enough). This gave me best results.
3. If you use only several classes, you can copy their .cpp files directly to your project source folder. Remember to add parent classes, too (see STK site -> Classes). Again I recommend that you give the compiler path to include folder you've unzipped, but copying only selected headers should also work.
I've found this article helpful (see also A1): http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/
Hope I've helped

CMake - set_property could not find TARGET xxx. Perhaps it has not yet been created

Greetings, what I'm trying to do is to port an existing Windows application to Linux using CMake with CMakeLists, which I generated with the vcproj2cmake Script (https://github.com/sixman9/vcproj2cmake).
With the CMakeLists.txt and CMake I was able to successfully port a VS 2005 project to VS 2010. Now I try to port the same VS 2005 project to Linux, so that I can edit it with KDevelope.
The project itself is small and I think it would be easier to just create a new project and copy all relevant files (if that would work), the problem is, that it's not only one project but many, hence I was looking for a way to port a project in an as simple as possible way.
In Linux I was able to create a CMakeLists.txt using the vcproj2cmake script. The next step would be creating a KDevelope project using CMake. And this is where I'm stuck.
Everytime I try to run CMake I get the following error:
CMake Error at CMakeLists.txt: 196 (set_property) :
set_property could not find TARGET Test_Project. Perhaps it has not yet been
created.
Test_Project: installing /root/Desktop/Test_Project/vs8/CMakeLists. txt rebuilder (watching /root/Desktop/Test_Project/vs8/Test_Project. vcproj)
Configuring incomplete, errors occurred!
See also “/root/Desktop/Test_Project/vs8/CMakeFiles/CMakeOutput.log”.
I searched for a solution or an approach for quite a time now, but the only results that I get are project-specific, or at least I think they are.
Content of the CMakeLists.txt from line 196:
set_property(TARGET Test_Project PROPERTY PROJECT_LABEL "Test_Project")
v2c_rebuild_on_update(Test_Project "${CMAKE_CURRENT_SOURCE_DIR}/Test_Project.vcproj" ${CMAKE_CURRENT_LIST_FILE} "vcproj2cmake.rb" ".")
include(${V2C_HOOK_POST} OPTIONAL)
Perhaps there are more efficient ways to port many projects form Windows to Linux, I'm open for any suggestion.
It is a bit difficult to help without having your project - since you are using a third party tool to convert a VC project you should ask the author of that tool. :D
If you have many projects which you are going to maintain, I suggest that you select one where you can create a cross platform (Windows/Linux) CMake config for which you can reuse for other projects.
Most of the config should be the same for all platforms you are building for - the difference should be which generator is used and what libraries to link in the final executable (if you are building one that is). The generator is specified when running cmake.
In my opinion you should try an out of source build with the following structure:
/$COMMON_DIR/CMakeLists.txt
/CMakeLists.txt
/src/
/build/
/build/vcX
/build/generate_vcX.bat
/build/linux
/build/generate_linux.sh
$COMMON_DIR should contain the CMake code you expect to be common for all you projects - like a function to create a static library for a module which searches for files in /src and another function which can be used to add an executable for certain platform.
The CMakeLists.txt in the root of your project (repository, I assume) should call the functions defined in $COMMON_DIR and possibly add some project specific defines or link flags.

CVTRES.exe is discarding my DLL exported functions

I'm working on a project that creates a DLL in C for Windows CE 5.0 using STANDARDSDK_500. The project is relatively simple with just one C source file. What I've noticed is that when I clean and build the project using Visual Studio 2005, it fails to create my Import lib. When I tell Visual Studio to rebuild it, it correctly creates the import lib.
Turning on verbose linking, I discover that in the failure case (clean and build) CVTRES.exe is discarding my functions, like so:
Invoking CVTRES.exe:
/machine:thumb
/verbose
/out:"C:\...\Temp\lnkC7E.tmp"
/readonly
/windowsce
".\standardsdk_500 (armv4i)\release\WLTBApi.res"
Microsoft (R) Windows Resource To Object Converter Version 8.00.50727.42
...
adding resource. type:VERSION, name:1, language:0x0409, flags:0x30, size:892
Discarded '.idata$4' from coredll.lib(COREDLL.dll)
...
Discarded WLRegisterStartupApp from WLTBApi.obj // my functions! Oh noes!
...
This discards all of my functions, which causes the linker to not create an import lib because there are no exported functions.
I figured that the input was the .res file mentioned in the commandline - WLTBApi.res. This file is identical in the intermediate directory after trying to compile both the working way (rebuild) and the non-working way (clean. build).
So, my first question is: what are the other inputs to the CVTRES.exe program so that I can find discrepencies between the two builds?
Second: what other troubleshooting techniques would you recommend?
Additional Info - I thought perhaps the .obj files were additional inputs - they differ between the builds. I now believe that they are outputs of CVTRES.exe. If anyone knows whether or not I'm correct in this, let me know.
Okay, so I found a solution, but I'm terribly dissatisfied with it. I discovered that the project I was building had a Dependency, but one that wasn't actually a dependency. In other words, the project, WLTBApi was building a DLL, and had a dependency configured, WLTBApiLib, but it wasn't actually using any of the output of that project. By removing the dependency, the problem went away.
I'd still love to know more about how to find an actual answer to what was going on, but maybe this answer will help someone else in the future.

Problems linking static libraries in Xcode 4

All was right in the world until I upgraded to Xcode 4 a few days ago. Since then I've had endless problems getting things to work as they should. And I have a crucial update I need to release. I've tried every permutation of settings I can think of, restarted, reinstalled Xcode, reverted to old versions of my files, everything.
My project links to three static libraries, contained in three other projects. I have used the standard processes to link libraries (drag the project files into mine, add their products as target dependencies, add the lib---.a files to the Link Binary With Libraries phase). And actually, I have no problem compiling with the Debug Build Configuration, either for the simulator or my test device.
Where everything goes sideways is when I compile with the Release Build Configuration, or when I try to Archive. I've gotten many different errors depending on my settings, but most are variations on this:
ld: warning: ignoring file
[...]/Build/Products/Debug-iphonesimulator/libGDataTouchStaticLib.a,
file was built for archive which is
not the architecture being linked
(armv6) Undefined symbols for
architecture armv6:
"_OBJC_CLASS_$_GDataSpreadsheetData",
referenced from:
objc-class-ref in ExportViewController.o
I can't understand why it's even looking at Products in the Debug-iphonesimulator directory (I swear, everything I'm linking to reveals itself in the Finder to be in the proper Release-iphoneos directory).
I have put a ridiculous number of hours into fixing this, really need help! Thank you!
Please check this question and answer. I encountered same problem and fixed it.
Xcode4 Linking Problem. File was built for archive which is not the architecture being linked (arm6)
I solved this problem by copying the .a lib files from the Release-iphoneos directory to the Debug-iphonesimulator directory so that the correct files would be found even though Xcode was looking in the wrong directory.
However, then I encountered the problem raised here of a multi-application bundle -- and the solution given didn't work for me. Finally gave up and reinstalled Xcode 3. Compiled, archived, and uploaded to the App Store in 20 minutes. Will be some time, and several dot-releases, before I give Xcode 4 another shot.
You may have -DGDATA_REQUIRE_SERVICE_INCLUDES=1 enabled in your other C flags for the GDataTouchStaticLib target. If so, add the service you need, in this case, spreadsheets, by adding -DGDATA_INCLUDE_SPREADSHEET_SERVICE=1 to your Other C Flags. Or if you don't want GData to require service includes (which will build everything into the static lib, not just what you need), just remove the DGDATA_REQUIRE_SERVICE_INCLUDES flag.

Resources