小编Mih*_*aru的帖子

boost test - 'undefined reference'错误

我有两个简单的文件:

runner.cpp:

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE Main
#include <boost/test/unit_test.hpp>
Run Code Online (Sandbox Code Playgroud)

和test1.cpp:

#define BOOST_TEST_DYN_LINK
#ifdef STAND_ALONE
#   define BOOST_TEST_MODULE Main
#endif
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE( Foo)

BOOST_AUTO_TEST_CASE( TestSomething )
{
    BOOST_CHECK( true );
}

BOOST_AUTO_TEST_SUITE_END()
Run Code Online (Sandbox Code Playgroud)

要编译,我正在使用:

$ g++ -I/e/code/boost_1_52_0 -o runner -lboost_unit_test_framework runner.cpp test1.cpp
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0x8c): multiple definition of `main'
c:/pdev/mingw/bin/../lib/gcc/i686-pc-mingw32/4.7.2/../../../libboost_unit_test_framework.a(unit_test_main.o):unit_test_main.cpp:(.text.startup+0x0): first defined here
c:/pdev/mingw/bin/../lib/gcc/i686-pc-mingw32/4.7.2/../../../libboost_unit_test_framework.a(unit_test_main.o):unit_test_main.cpp:(.text.startup+0x14): undefined reference to `init_unit_test_suite(int, char**)'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0x52): undefined reference to `_imp___ZN5boost9unit_test9framework17master_test_suiteEv'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text+0xb0): undefined reference to `_imp___ZN5boost9unit_test14unit_test_mainEPFbvEiPPc'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text$_ZN5boost9unit_test13test_observerD2Ev[__ZN5boost9unit_test13test_observerD2Ev]+0xe): undefined reference to `_imp___ZTVN5boost9unit_test13test_observerE'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text$_ZN5boost9unit_test13test_observerC2Ev[__ZN5boost9unit_test13test_observerC2Ev]+0xe): undefined reference to `_imp___ZTVN5boost9unit_test13test_observerE'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccU0cDSz.o:runner.cpp:(.text$_ZN5boost9unit_test15unit_test_log_tC1Ev[__ZN5boost9unit_test15unit_test_log_tC1Ev]+0x22): undefined reference …
Run Code Online (Sandbox Code Playgroud)

c++ boost unit-testing mingw boost-test

6
推荐指数
1
解决办法
1万
查看次数

内部div的100%高度无法在最小高度的div内工作

我有div(#child),不会扩展到其父级(#parent)的整个高度。我已经设定了html和的高度body。如果将父级的高度设置为100%,但我希望父级具有最小高度,并且子级可以扩展到父级的全高,则它可以工作。

HTML:

<html>
    <body>
        <div id="parent">
          <div id="child">
              <p>This area should be have the same height as it's parent.</p>
           </div>
        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

CSS:

html, body, header, h1, p { margin: 0; padding: 0; }

html         { background-color: #DDD; height: 100%; }
body         { background-color: #DAA; height: 100%; }

#parent {
  min-height: 70%;
  height: auto !important;
  height: 70%;

  background-color: #AAD;
}

#child {
  height: 100%; /* why isn't this working ? */ …
Run Code Online (Sandbox Code Playgroud)

html css layout

5
推荐指数
1
解决办法
5126
查看次数

我为什么要买这些Silex 404?

刚开始使用Silex并遇到一些问题.

下载的脂肪压缩文件,解压成wampwww文件夹中.所以,这是C:\wamp\www\fat-silex\web\index.php:

<?php
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello', function() {
    return 'Hello!';
});
$app->run();
Run Code Online (Sandbox Code Playgroud)

问题是我正在获取Apache的404 http://localhost/fat-silex/web/hello,以及任何URL,除了localhost/fat-silex/web我正在获得Silex'es 404(正如预期的那样).我猜这些请求直接发送到Apache,并且不会被Silex路由.看起来问题可以用.htaccess文件解决,所以我在官方文档中建议添加了这个:

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    RewriteBase /fat-silex
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

但是,它似乎没有任何影响.

php apache .htaccess wamp silex

3
推荐指数
1
解决办法
3323
查看次数

子类不继承祖父项属性

我有以下C++代码:

#include <iostream>
#include <string>
using namespace std;

class Surface
{
public:
    virtual void draw();
protected:
    int x,y;
};

class Control: public Surface
{
public:
    Control(): x(10), y(10), name("control") { cout << "Control constructor" << endl; }
    void draw() {}
protected:
    string name;
};

class Label: public Control
{
public:
    Label(): x(10), y(10), name("label"), text("label") { cout << "Label constructor" << endl; }
    void draw() { cout << "drawing a label" << endl; }

protected:
    string text;
};

int main(int …
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
1978
查看次数

标签 统计

c++ ×2

.htaccess ×1

apache ×1

boost ×1

boost-test ×1

css ×1

html ×1

layout ×1

mingw ×1

php ×1

silex ×1

unit-testing ×1

wamp ×1