Discussion:
[Cucumber] Cucumber-cpp some LINK errors
(too old to reply)
Shareef Chachu
2017-07-14 06:52:52 UTC
Permalink
Raw Message
I am testing a c++ program using Cucumber framework. Documentation for
Cucumber-cpp <https://github.com/cucumber/cucumber-cpp>. Basically, I
needed to include some of the library files such as boost, gtest etc. Also,
build Ruby Cucumber gem. I have finished all of them.


I am currently using visual studio 2017 community version. From the
documentation of cucumber-cpp, I downloaded the file and started trying one
of the examples they provided (Calc). I added the header file (
*Calculator.h*), source file (*Calculator.cpp)*, test file (
*GtestCalculatorSteps.cpp*) and finally *addition.feature*.


After debugging, I get some link errors. *I have attached a screenshot of
the errors. *


Can anyone help me by telling how do I fix this?
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Paolo Ambrosio
2017-07-17 06:10:40 UTC
Permalink
Raw Message
Post by Shareef Chachu
I am testing a c++ program using Cucumber framework. Documentation for
Cucumber-cpp. Basically, I needed to include some of the library files such
as boost, gtest etc. Also, build Ruby Cucumber gem. I have finished all of
them.
I am currently using visual studio 2017 community version. From the
documentation of cucumber-cpp, I downloaded the file and started trying one
of the examples they provided (Calc). I added the header file
(Calculator.h), source file (Calculator.cpp), test file
(GtestCalculatorSteps.cpp) and finally addition.feature.
After debugging, I get some link errors. I have attached a screenshot of the
errors.
Can anyone help me by telling how do I fix this?
Hi Shareef,

To compile step definitions in Cucumber-CPP you need to link them to
the Cucumber-CPP static library (that is produced by the project
root), Boost libraries (thread, system, regex, date_time,
program_options, filesystem) and GoogleTest or Boost::Test depending
on the chosen testing framework.

If you look at the CMakeLists.txt in the Calc example
(https://github.com/cucumber/cucumber-cpp/blob/master/examples/Calc/CMakeLists.txt)
you'll find:

target_link_libraries(BoostCalculatorSteps Calc ${CUKE_LIBRARIES}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})

This means that to link BoostCalculatorSteps , you need:
- the Calc library (system under test)
- the Cucumber-CPP library and the Boost libraries (listed above)
- Boost::Test

For GTestCalculatorSteps, you need to replace Boost::Test with
GoogleTest instead.


HTH,
Paolo
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Shareef Chachu
2017-07-18 05:13:13 UTC
Permalink
Raw Message
Thanks for the reply. By the way, I was using the
*GtestCalculatorSteps.cpp. *I think the thread has itself an error. Which
is, both the *GtestCalculatorSteps.cpp *and *Boost**CalculatorSteps.cpp *are
same. No difference. Do you have the corrected version of it?
cucumber->example->calc->step definitions->GtestCalculatorSteps.cpp
Post by Paolo Ambrosio
Post by Shareef Chachu
I am testing a c++ program using Cucumber framework. Documentation for
Cucumber-cpp. Basically, I needed to include some of the library files
such
Post by Shareef Chachu
as boost, gtest etc. Also, build Ruby Cucumber gem. I have finished all
of
Post by Shareef Chachu
them.
I am currently using visual studio 2017 community version. From the
documentation of cucumber-cpp, I downloaded the file and started trying
one
Post by Shareef Chachu
of the examples they provided (Calc). I added the header file
(Calculator.h), source file (Calculator.cpp), test file
(GtestCalculatorSteps.cpp) and finally addition.feature.
After debugging, I get some link errors. I have attached a screenshot of
the
Post by Shareef Chachu
errors.
Can anyone help me by telling how do I fix this?
Hi Shareef,
To compile step definitions in Cucumber-CPP you need to link them to
the Cucumber-CPP static library (that is produced by the project
root), Boost libraries (thread, system, regex, date_time,
program_options, filesystem) and GoogleTest or Boost::Test depending
on the chosen testing framework.
If you look at the CMakeLists.txt in the Calc example
(
https://github.com/cucumber/cucumber-cpp/blob/master/examples/Calc/CMakeLists.txt)
target_link_libraries(BoostCalculatorSteps Calc ${CUKE_LIBRARIES}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
- the Calc library (system under test)
- the Cucumber-CPP library and the Boost libraries (listed above)
- Boost::Test
For GTestCalculatorSteps, you need to replace Boost::Test with
GoogleTest instead.
HTH,
Paolo
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Shareef Chachu
2017-07-18 06:13:08 UTC
Permalink
Raw Message
Thanks for the reply. By the way I am using GtestCucumberCalc.cpp.
I just skipped that example and started my own after your suggestions here.



*My header code is:*

#include <cmath>
#include<stdio.h>
#include <conio.h>

int addNumbers(int a, int b)
{
return a + b;
}



*My Google test code is**:* (I tried the gtest and its working)

// unittest_SimpleMath.cpp : Defines the entry point for the console
application.

#include "gtest/gtest.h"
#include "simplemath.h"

TEST(testMath, addTest)
{
EXPECT_EQ(12, addNumbers(10, 2));
getchar();
}

I was wondering if you could help to do the cucumber test? How shall I do
the cucumber testing?
Post by Shareef Chachu
I am testing a c++ program using Cucumber framework. Documentation for
Cucumber-cpp. Basically, I needed to include some of the library files
such
Post by Shareef Chachu
as boost, gtest etc. Also, build Ruby Cucumber gem. I have finished all
of
Post by Shareef Chachu
them.
I am currently using visual studio 2017 community version. From the
documentation of cucumber-cpp, I downloaded the file and started trying
one
Post by Shareef Chachu
of the examples they provided (Calc). I added the header file
(Calculator.h), source file (Calculator.cpp), test file
(GtestCalculatorSteps.cpp) and finally addition.feature.
After debugging, I get some link errors. I have attached a screenshot of
the
Post by Shareef Chachu
errors.
Can anyone help me by telling how do I fix this?
Hi Shareef,
To compile step definitions in Cucumber-CPP you need to link them to
the Cucumber-CPP static library (that is produced by the project
root), Boost libraries (thread, system, regex, date_time,
program_options, filesystem) and GoogleTest or Boost::Test depending
on the chosen testing framework.
If you look at the CMakeLists.txt in the Calc example
(
https://github.com/cucumber/cucumber-cpp/blob/master/examples/Calc/CMakeLists.txt)
target_link_libraries(BoostCalculatorSteps Calc ${CUKE_LIBRARIES}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
- the Calc library (system under test)
- the Cucumber-CPP library and the Boost libraries (listed above)
- Boost::Test
For GTestCalculatorSteps, you need to replace Boost::Test with
GoogleTest instead.
HTH,
Paolo
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...