【发布时间】:2011-04-28 08:32:32
【问题描述】:
我有一个 my.h 文件:
#ifndef __MY__
#define __MY__
#include <string>
#include <time.h>
class S
{
public: S();
std::string myname;
};
#endif
我的.cpp
#include "my.h";
#include<string>
#include<iostream>
using namespace std;
S::S()
{
// .. code
}
我想创建一个so文件。创建时没有错误。但是当我编译 .h 文件时,它说:字符串:没有这样的文件或目录。如果我 pus string.h 而不是 string 我有错误:在 my.h 中的 S(在 S 类)之前预期的 '=',',',';','asm'。 在 .cpp 文件中(如果我用 string.h 更改字符串)我在编译后出现错误:命名空间 std 中的字符串没有命名类型。我哪里错了?
【问题讨论】:
-
你的编译命令行是什么?顺便说一句,
__MY__这样的名称不允许在用户编写的代码中创建。 -
另外最好去掉
my.cpp第一行的分号 -
我正在使用 geany 代码。我给构建
-
在 test.cpp 我正在调用 .so 文件: void* handle = dlopen("/home/path/test.so", RTLD_NOW); if(!handle)0 { cout