Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译报错,多次定义,编译-用的std=c++11 #1

Open
wanghongfucoder opened this issue Mar 11, 2019 · 5 comments
Open

编译报错,多次定义,编译-用的std=c++11 #1

wanghongfucoder opened this issue Mar 11, 2019 · 5 comments

Comments

@wanghongfucoder
Copy link

:在函数‘emock::InvocationMockBuilderGetter emock::mockAPI(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, char const*)’中:
reg_son_log.cpp:(.text+0x4d): emock::InvocationMockBuilderGetter emock::mockAPI(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, char const*) 的多重定义
CMakeFiles/main.dir/main.cpp.o:main.cpp:(.text+0x4d):第一次在此定义
src/libMysrc.a(grammar.cpp.o):在函数‘emock::InvocationMockBuilderGetter emock::mockAPI(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, char const*)’中:
grammar.cpp:(.text+0xf1): emock::InvocationMockBuilderGetter emock::mockAPI(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, char const*) 的多重定义
CMakeFiles/main.dir/main.cpp.o:main.cpp:(.text+0x4d):第一次在此定义
src/libMysrc.a(stonewt.cpp.o):在函数‘emock::InvocationMockBuilderGetter emock::mockAPI(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, char const*)’中:
stonewt.cpp:(.text+0x4d): emock::InvocationMockBuilderGetter emock::mockAPI(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, char const*) 的多重定义
CMakeFiles/main.dir/main.cpp.o:main.cpp:(.text+0x4d):第一次在此定义

@orca-zhang
Copy link
Member

抱歉,前些日子出去度假了,今天抽空我看一下,初步看是条件编译的问题。

@orca-zhang
Copy link
Member

非常抱歉,之前因为加班和其他原因,文档还未及时补全,导致使用手册缺失。
想麻烦问一下,目前是怎么使用的呢,正确姿势只需包含 emock.hpp 即可。

@wanghongfucoder
Copy link
Author

是这样的,我先在本地编译成功后,得到静态lib,然后把头文件加入include文件夹下,并在CMakeLists中加入该目录,并且一同将静态lib加入lib目录中,进行链接,
.
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── cmake_install.cmake
│   ├── compile_commands.json
│   ├── main
│   ├── Makefile
│   └── src
├── CMakeLists.txt
├── CplusDemo.code-workspace
├── include
│   ├── common.h
│   ├── concurrency
│   ├── ctrl.h
│   ├── emock
│   ├── grammar
│   ├── gtest
│   ├── ios
│   ├── json.hpp
│   ├── memory
│   └── stl
├── lib
│   ├── libemock.a
│   └── libgtest.so
├── main.cpp
├── README.md
├── src
│   ├── CMakeLists.txt
│   ├── concurrency
│   ├── grammar
│   ├── ios
│   ├── memory
│   ├── stl
│   └── string

@orca-zhang
Copy link
Member

好的,收到反馈,我也尝试本地复现一下。

@orca-zhang
Copy link
Member

如果是在msvc环境下,实在无法很快解决,也可以考虑在编译选项中添加“/FORCE:MULTIPLE”来强制忽略重复定义的错误哈。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants