Cannot build CppUTest on cygwin (x64)

1,103 views
Skip to first unread message

cp engr

unread,
Nov 14, 2014, 1:01:41 PM11/14/14
to cppu...@googlegroups.com
I can't build CppUTest in Cygwin x64 on Win7 x64 (SP1). What am I missing or doing wrong?

I git cloned git://github.com/cpputest/cpputest.git.

I've installed gcc-g++, cmake, and make in Cygwin. (What other prerequisites are there?)

I see two methods to build, in README.md, under "Getting Started":

1. "Building from source (unix-based, cygwin, MacOSX)".
2. "You can also use CMake...".

**************************************************

Attempting method 1, I get:

me@mypc /cygdrive/c/Users/me/Documents/proj/cpputest
$ ./autogen.sh
./autogen.sh: line 7: autoreconf: command not found

**************************************************

Attempting method 2, I get:

me@mypc /cygdrive/c/Users/me/Documents/proj/cpputest
$ cmake CMakeLists.txt
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is GNU 4.8.3
CMake Warning at /usr/share/cmake-2.8.11.2/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!

(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.

(2) If you are developing this project, add the line

set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required

at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/usr/share/cmake-2.8.11.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:1 (project)


-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.

It fails with the following output:

Change Dir: /cygdrive/c/Users/pmt037/Documents/proj/cpputest/CMakeFiles/CMakeTmp

Run Build Command:/cygdrive/c/ruby-2.0-devkit-mingw64-4.7.2/bin/make.exe
"cmTryCompileExec3773552349/fast"

/usr/bin/make -f CMakeFiles/cmTryCompileExec3773552349.dir/build.make
CMakeFiles/cmTryCompileExec3773552349.dir/build

make[1]: Entering directory
`/c/Users/pmt037/Documents/proj/cpputest/CMakeFiles/CMakeTmp'

/usr/bin/cmake.exe -E cmake_progress_report
/cygdrive/c/Users/pmt037/Documents/proj/cpputest/CMakeFiles/CMakeTmp/CMakeFiles
1

make[1]: /usr/bin/cmake.exe: Command not found

make[1]: Leaving directory
`/c/Users/pmt037/Documents/proj/cpputest/CMakeFiles/CMakeTmp'

make[1]: *** [CMakeFiles/cmTryCompileExec3773552349.dir/testCCompiler.c.o]
Error 127

make: *** [cmTryCompileExec3773552349/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)


-- Configuring incomplete, errors occurred!

**************************************************

Thanks.

cp engr

unread,
Nov 14, 2014, 1:53:58 PM11/14/14
to cppu...@googlegroups.com
Also, when I open CppUTest.vcxproj in MS Visual Studio 2010, right-click the CppUTest project and choose "Build", (it first prompts me to save the .sln file, then) it fails to build. I get the following Output:


1>------ Rebuild All started: Project: CppUTest, Configuration: Debug Win32 ------
1>Build started 11/14/2014 1:48:49 PM.
1>_PrepareForClean:
1> Deleting file ".\Debug\CppUTest.lastbuildstate".
1>InitializeBuildStatus:
1> Touching ".\Debug\CppUTest.unsuccessfulbuild".
1>ClCompile:
1> CodeMemoryReportFormatter.cpp
1> MemoryReportAllocator.cpp
1> MemoryReporterPlugin.cpp
1> MemoryReportFormatter.cpp
1> MockActualCall.cpp
1> MockExpectedCall.cpp
1> MockExpectedCallsList.cpp
1> MockFailure.cpp
1> MockNamedValue.cpp
1> MockSupport.cpp
1> MockSupportPlugin.cpp
1> MockSupport_c.cpp
1> OrderedTest.cpp
1> CommandLineArguments.cpp
1> CommandLineTestRunner.cpp
1> JUnitTestOutput.cpp
1> MemoryLeakDetector.cpp
1> MemoryLeakWarningPlugin.cpp
1> SimpleMutex.cpp
1> SimpleString.cpp
1> Generating Code...
1> Compiling...
1> TestFailure.cpp
1> TestFilter.cpp
1> TestHarness_c.cpp
1> TestMemoryAllocator.cpp
1> TestOutput.cpp
1> TestPlugin.cpp
1> TestRegistry.cpp
1> TestResult.cpp
1> Utest.cpp
1> UtestPlatform.cpp
1> Generating Code...
1>Lib:
1> CppUTest.vcxproj -> C:\Users\me\Documents\proj\cpputest\.\Debug\CppUTestd.lib
1>PostBuildEvent:
1> The system cannot find the path specified.
1> 0 file(s) copied.
1> The system cannot find the path specified.
1> 0 file(s) copied.
1> The system cannot find the path specified.
1> 0 file(s) copied.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy .\Debug\CppUTestd.lib lib\vs2010
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: copy .\Debug\CppUTestd.lib lib\CppUTestd.lib
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: copy .\Debug\vc100.pdb lib\vs2010
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 1.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:10.95
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

A. Robert S.

unread,
Nov 17, 2014, 8:55:58 AM11/17/14
to cppu...@googlegroups.com
Hi,
 
As for the first method, you need autotools installed. Alternatively, you could download the latest .zip archive and build from that, which should not require autotools.
 
I don't know much about CMake :-/
 
Visual Studio has actually built your libraries fine; you could copy them manually into the lib/ folder. There is something wrong with the post-build copy command; I've seen this before & I thought this was fixed. You may also be able to manually correct that command.
 
Hope this helps!
Robert

A. Robert S.

unread,
Nov 17, 2014, 8:57:02 AM11/17/14
to cppu...@googlegroups.com
P.S. You can install autotools from Cygwin.

James Grenning

unread,
Nov 18, 2014, 1:21:18 PM11/18/14
to cppu...@googlegroups.com
The copy operation fails because the lib destination directory does not
exist.
At the time there was no windows way to mkdir if it did not exist (like
linux mkdir -p).

That copy operation could be removed. It seems to cause more problems
than it helps solve. I put that in long ago when I had several MS VS
versions I was testing. Now I rarely use MS VS. Maybe no one uses that
capability.

James

------------------------------------------------------------------
James Grenning Author of TDD for Embedded C
www.wingman-sw.com http://pragprog.com/titles/jgade/
www.wingman-sw.com/#blog
www.twitter.com/jwgrenning
facebook.com/wingman.sw
> --
> You received this message because you are subscribed to the Google
> Groups "cpputest" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to cpputest+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

cp engr

unread,
Nov 19, 2014, 4:34:19 PM11/19/14
to cppu...@googlegroups.com
Hi Robert,

> As for the first method, you need autotools installed.

I don't see autotools listed in the packages list for Cygwin. I did find and install autoconf, however. Now I get

me@mypc /cygdrive/c/Users/me/Documents/proj/cpputest
$ ./autogen.sh
Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf-2.69: failed to run aclocal: No such file or directory

...which seems to be a step in the right direction.

> P.S. You can install autotools from Cygwin.

How/where?

Thanks,

cpengr

cp engr

unread,
Nov 19, 2014, 4:56:15 PM11/19/14
to cppu...@googlegroups.com
James,

> The copy operation fails because the lib destination directory does not exist.

I see that you are talking about the copy that failed when I tried to build CppUTest in Visual Studio. I created a lib directory, and the build succeeded.

> At the time there was no windows way to mkdir if it did not exist (like linux mkdir -p).

Not sure what you're saying here. Looks like there's just one directory (lib) that needs to be created, and it's a child of the project directory, so it's not nested under some other directory that also has to be created.

Anyway, if I understand the purpose, it's just to copy the useful output out of the Debug folder. This seems useful. If there's no good way to change whatever post-build scripts or events to create it (really?), then maybe you can just commit the folder to the repo (say with an empty file to make it stick).

So with the library built in Visual Studio...I'm trying to figure out what to do next.

I'm working on two projects for devices that talk to each other across a serial medium. One project is in Keil µVision; the other is in Visual Studio.

Some questions that come to mind are:

1. Will the .lib file I built in VS work in other IDEs / with different compilers?

2. As a matter of recommended practice / workflow, should I be aiming for the ability to run the tests from the IDEs?

2.a. If so, then as a pre- or post-build event?

Sorry if any of this is basic stuff. Please feel free to point me to any relevant resources, or even provide search terms if you sense I'm lacking some particular background knowledge.

For the record (i.e. so you can know your audience), I do have some experience doing TDD with Ceedling. We were running tests and building with gcc from the command line with make. (Separate events.) Cygwin in my case; Linux for some other developers. I just used it; I didn't setup the toolchain or environment, though.

Great book, BTW. :)

Thanks,

cpengr

cp engr

unread,
Nov 19, 2014, 5:13:40 PM11/19/14
to cppu...@googlegroups.com
OK...now I parsed from the homepage that I needed to install automake, autoconf, and libtool (all of which I found in the Cygwin packages). My new output from autogen.sh (method 1) is below. It appears possibly successful, but with lots of warnings.

Then

cd cpputest_build
autoreconf .. -i

produces a similar set of warnings.

----------------------------------------------------------------------

me@mypc /cygdrive/c/Users/me/Documents/proj/cpputest
$ ./autogen.sh
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
configure.ac:10: installing './compile'
configure.ac:10: installing './config.guess'
configure.ac:10: installing './config.sub'
configure.ac:4: installing './install-sh'
configure.ac:4: installing './missing'
Makefile.am: installing './INSTALL'
Makefile.am:35: warning: source file 'src/CppUTest/CommandLineArguments.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
automake-1.14: warning: possible forward-incompatibility.
automake-1.14: At least a source file is in a subdirectory, but the 'subdir-objects'
automake-1.14: automake option hasn't been enabled. For now, the corresponding output
automake-1.14: object file(s) will be placed in the top-level directory. However,
automake-1.14: this behaviour will change in future Automake versions: they will
automake-1.14: unconditionally cause object files to be placed in the same subdirectory
automake-1.14: of the corresponding sources.
automake-1.14: You are advised to start using 'subdir-objects' option throughout your
automake-1.14: project, to avoid future incompatibilities.
Makefile.am:35: warning: source file 'src/CppUTest/CommandLineTestRunner.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/JUnitTestOutput.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/MemoryLeakDetector.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/MemoryLeakWarningPlugin.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/SimpleString.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/SimpleMutex.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestFailure.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestFilter.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestHarness_c.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestMemoryAllocator.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestOutput.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestPlugin.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestRegistry.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/TestResult.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/CppUTest/Utest.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:35: warning: source file 'src/Platforms/$(CPP_PLATFORM)/UtestPlatform.cpp' is in a subdirectory,
Makefile.am:35: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/CodeMemoryReportFormatter.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MemoryReportAllocator.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MemoryReporterPlugin.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MemoryReportFormatter.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockActualCall.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockExpectedCall.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockExpectedCallsList.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockFailure.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockNamedValue.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockSupport.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockSupportPlugin.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/MockSupport_c.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:87: warning: source file 'src/CppUTestExt/OrderedTest.cpp' is in a subdirectory,
Makefile.am:87: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/AllTests.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/CodeMemoryReportFormatterTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/GMockTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/GTest1Test.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/GTest2ConvertorTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MemoryReportAllocatorTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MemoryReporterPluginTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MemoryReportFormatterTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockActualCallTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockCheatSheetTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockExpectedCallTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockExpectedFunctionsListTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockFailureTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockPluginTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockSupportTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockSupport_cTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/MockSupport_cTestCFile.c' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:169: warning: source file 'tests/CppUTestExt/OrderedTestTest.cpp' is in a subdirectory,
Makefile.am:169: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/AllocationInCFile.c' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/AllocationInCppFile.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/AllocLetTestFree.c' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/AllocLetTestFreeTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/AllTests.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/CheatSheetTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/CommandLineArgumentsTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/CommandLineTestRunnerTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/JUnitOutputTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/MemoryLeakDetectorTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/MemoryLeakOperatorOverloadsTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/MemoryLeakWarningTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/PluginTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/PreprocessorTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/SetPluginTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/SimpleStringTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/SimpleMutexTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestFailureNaNTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestFailureTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestFilterTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestHarness_cTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestHarness_cTestCFile.c' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestInstallerTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestMemoryAllocatorTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestOutputTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestRegistryTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestResultTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/TestUTestMacro.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am:132: warning: source file 'tests/UtestTest.cpp' is in a subdirectory,
Makefile.am:132: but option 'subdir-objects' is disabled
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'

James Grenning

unread,
Nov 19, 2014, 8:30:31 PM11/19/14
to cppu...@googlegroups.com

On 19 Nov 2014, at 15:56, cp engr wrote:

> James,
>
>> The copy operation fails because the lib destination directory does
>> not exist.
>
> I see that you are talking about the copy that failed when I tried to
> build CppUTest in Visual Studio. I created a lib directory, and the
> build succeeded.
>
>> At the time there was no windows way to mkdir if it did not exist
>> (like linux mkdir -p).
>
> Not sure what you're saying here.

It could not be created in the post build event, because it could fail
if the dir exists, like in a rebuild.

> Looks like there's just one directory (lib) that needs to be created,
> and it's a child of the project directory, so it's not nested under
> some other directory that also has to be created.

If you manually create the directory, that will probably help.
>
> Anyway, if I understand the purpose, it's just to copy the useful
> output out of the Debug folder. This seems useful. If there's no good
> way to change whatever post-build scripts or events to create it
> (really?), then maybe you can just commit the folder to the repo (say
> with an empty file to make it stick).

Seems that the zip process, at least when I was doing this, would not
include empty directories. This could have changed, in later
windows/zip versions.


>
> So with the library built in Visual Studio...I'm trying to figure out
> what to do next.
>
> I'm working on two projects for devices that talk to each other across
> a serial medium. One project is in Keil µVision; the other is in
> Visual Studio.
>
> Some questions that come to mind are:
>
> 1. Will the .lib file I built in VS work in other IDEs / with
> different compilers?

No, libs are compiler and likely system dependent.

You have to get used to the idea of separate production and test builds.
Get your Keil code to compile under windows and unit test it there.

>
> 2. As a matter of recommended practice / workflow, should I be aiming
> for the ability to run the tests from the IDEs?
>

Take VS for example, you should be able to press something like
control-f5, or was that control f-7, or... to save-all and initiate a
build followed by a console test run.

If yo can run from the VS IDE, you will get a command line build for
free with MSBUILD. You want a command line build also for continuous
integration.

If you choose to do on-target test runs, doing that from the IDE and
command line will probably be helpful.

The thing to work towards is a very short feedback cycle while
programming red-green-refactor cycle. The test build should be measured
in seconds not minutes. If you have a large system, you may need
several test builds. Also build should work like CppUTest's build that
only builds what is necessary. Also, a fast computer helps.

> 2.a. If so, then as a pre- or post-build event?

I've gone back and forth on post-build event for running tests. Where
there is a test failure, VS gets confused and thinks it may be a build
failure.

I'd look to setup the IDE to have a single key press or chord to run the
tests. For example, ellipse on mac command-shift-s along with "build on
resource save" and "build automatically" will run the designated
makefile and target. You can elect the target that runs the tests after
the build.

>
> Sorry if any of this is basic stuff. Please feel free to point me to
> any relevant resources, or even provide search terms if you sense I'm
> lacking some particular background knowledge.
>
> For the record (i.e. so you can know your audience), I do have some
> experience doing TDD with Ceedling. We were running tests and building
> with gcc from the command line with make. (Separate events.) Cygwin in
> my case; Linux for some other developers. I just used it; I didn't
> setup the toolchain or environment, though.
>
> Great book, BTW. :)

thanks! (did you write a review on amazon? tell your friends! :-)

>
> Thanks,
>
> cpengr

cp engr

unread,
Nov 20, 2014, 11:25:42 AM11/20/14
to cppu...@googlegroups.com
>>> At the time there was no windows way to mkdir if it did not exist
>>> (like linux mkdir -p).
>>
>> Not sure what you're saying here.

> It could not be created in the post build event, because it could fail
> if the dir exists, like in a rebuild.

Oh, I see. I had forgotten that mkdir -p won't complain if the directory you're trying to create already exists.

> If you manually create the directory, that will probably help.

I did, and it did.

> Seems that the zip process, at least when I was doing this, would not
> include empty directories. This could have changed, in later
> windows/zip versions.

Not relevant to me personally, since I checked out from the repository.

However, I just did a quick test with the current version of Peazip, and it did preserve an empty subfolder.

I'll make a separate post with questions.

cp engr

unread,
Nov 20, 2014, 2:43:10 PM11/20/14
to cppu...@googlegroups.com
Between the time I sent my last message and now, I found docs/WalkThrough_VS21010.docx, which answered most of the questions I was going to ask.

Now I've got a cpputest project and a MyProjUnitTests project added to my solution. I can build it as long as I don't try to call any functions from MyProj!

When I do try to call one of the functions from MyProj, I get

2>ClCompile:
2> MyProjModuleTest.cpp
2> MyProjModuleTest.obj : error LNK2019: unresolved external symbol _MyModuleInit referenced in function "public: virtual void __thiscall TEST_MyModuleGroup_FirstTest_Test::testBody(void)" (?testBody@TEST_MyModuleGroup_FirstTest_Test@@UAEXXZ)
2>C:\[working_dir]\Projects\Debug\MyProjUnitTests.exe : fatal error LNK1120: 1 unresolved externals
2>
2>Build FAILED.

I've added all the same include directories to the MyProjUnitTests project as are included in MyProj.

What could be causing this error, and how might I resolve it?

Thanks,

cpengr

cp engr

unread,
Nov 20, 2014, 2:45:04 PM11/20/14
to cppu...@googlegroups.com
Hmm, maybe I should've started a new thread, since the subject line doesn't fit anymore?

James Grenning

unread,
Nov 20, 2014, 4:14:07 PM11/20/14
to cppu...@googlegroups.com
A common link failure is when a cpp file calls a c file that was not in
an extern "C" block. But given your error, it looks like
_MyModuleInit's declaration is in a an extern "C" block.

Presuming MyProj is in a static library, gives two possibilities I know
of:
1) You are not linking with the library that holds _MyModuleInit's
- to do this make MyProj a dependency of MyProjModuleTest project or add
the MyProj lib into linker input of MyProjModuleTest.

2) The test project and module project have different settings


--------------------------------------------------------------------------
James Grenning - Author of TDD for Embedded C -
pragprog.com/titles/jgade/
wingman-sw.com
wingman-sw.com/blog
twitter.com/jwgrenning
facebook.com/wingman.sw

cp engr

unread,
Nov 20, 2014, 4:44:04 PM11/20/14
to cppu...@googlegroups.com
> A common link failure is when a cpp file calls a c file that was not in
> an extern "C" block. But given your error, it looks like
> _MyModuleInit's declaration is in a an extern "C" block.

Correct.

> Presuming MyProj is in a static library, gives two possibilities I know
> of:

Actually, MyProj gets built into a DLL. Specifically, from the MyProj project properties:

Project Defaults:
Configuration Type: Dynamic Library (.dll)
Use of MFC: Use MFC in a Shared DLL
Use of ATL: Not Using ATL

> 1) You are not linking with the library that holds _MyModuleInit's
> - to do this make MyProj a dependency of MyProjModuleTest project or add
> the MyProj lib into linker input of MyProjModuleTest.

Can't do that, as it would create a circular dependency. (> A common link failure is when a cpp file calls a c file that was not in
> an extern "C" block. But given your error, it looks like
> _MyModuleInit's declaration is in a an extern "C" block.

Yes.

> Presuming MyProj is in a static library, gives two possibilities I know
> of:

I think not, actually. MyProj gets built into a DLL. Specifically, from the MyProj project properties:

Project Defaults:
Configuration Type: Dynamic Library (.dll)
Use of MFC: Use MFC in a Shared DLL
Use of ATL: Not Using ATL

> 1) You are not linking with the library that holds _MyModuleInit's
> - to do this make MyProj a dependency of MyProjModuleTest project or add
> the MyProj lib into linker input of MyProjModuleTest.

Can't do that, as it would create a circular dependency. (The MtProjUnitTests project depends on the MyProj project, per the walkthrough.)

> 2) The test project and module project have different settings

Which settings are you referring to that might affect it?

James Grenning

unread,
Nov 20, 2014, 5:02:51 PM11/20/14
to cppu...@googlegroups.com
Linking to a DLL... now we are firmly outside my experience. I know
some general stuff that might help.

Here are some things I'd look at:

1) Are you coding the entry point code to your DLL or does vs generate
that?
Said another way: is there part of your code that knows it is in a DLL?
---- if so: separate code that knows it is in a DLL from the business
logic (this is better design anyway to separate these concerns)
---- put the business logic in a staid lib. The only thing in the DLL
is the DLL entry point code

2) Do you have other code that calls code in a DLL? if so: go see how
that is done.

3) I recall in days past that MS also generated a static lib along with
the DLL to get more direct access.

cp engr

unread,
Nov 20, 2014, 7:47:54 PM11/20/14
to cppu...@googlegroups.com
Wow. That was...difficult. I'm not entirely sure how I tracked down all these things.

Anyway, below are all the things I had to change to get a test to build and pass. I think 1.a & 1.b may be mostly a matter of matching the settings in MyProj.

I'm not sure if 1.c and 2 are really the "right way" to do it, but it seems to be working.

Next up for me: figure out mocking...

Thanks for your help. :)

----------------------------------------------------------------------

1. MyProjUnitTests proj properties -> Configuration Properties ...

1.a. -> General -> Project Defaults -> Use of MFC -> Use of MFC in a Shared DLL
(same as MyProj)


1.b. -> C/C++ ...

1.b.1. -> General -> Additional Include Directories
...wherever the includes are for the stuff I want to test; and also some solution-wide includes (IDK why).

1.b.2. -> Precompiled Headers -> Precompiled Header -> Create (/Yc)

1.b.3. -> Advanced -> Forced Include File -> stdafx.h
(and inherit)


1.c. -> Linker ...

1.c.1. -> General -> Additional Library Directories -> $(OutDir)
(same as MyProj)

1.c.2. -> Input -> Additional Dependencies -> MyProj.lib
(and inherit)


2. Add .obj files built by MyProj that I want to test as Resource Files in MyProjUnitTests.

James Grenning

unread,
Nov 24, 2014, 2:58:35 PM11/24/14
to cppu...@googlegroups.com
Good job. It will be easier the next time :-)

I suggest you start with simple hand-crafted stubs. Experiment with
mocking by writing some tests for your mocks.

James

gp

unread,
Mar 26, 2015, 7:14:40 PM3/26/15
to cppu...@googlegroups.com
Hi,

I'm receiving the same errors.

Do you know how to get it running in Cygwin 64?


Thanks.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages