libreDWG を使用して、いくつかの dwg ファイルを開いて理解しようとしています。私はそれをインストールし、少なくともいくつかのテストプログラムを実行しました(後で障害が発生したとしても)。とにかく、ここにある簡単な例に非常によく似た小さなヘッダーファイルをプロジェクトに含めましたhttps://github.com/h4ck3rm1k3/libredwg/blob/master/examples/load_dwg.cデータに一般的な問題があるようですつまり、以前は (void*) と (unsigned char*) を型 ( char*) を追加し、これらのコンパイラの不満を取り除きました。しかし、それでもそのようにコンパイルしても
g++ xxx.c++ -L/opt/local/lib/ -lredwg -o program_name
次のエラーが表示されます。
Undefined symbols for architecture x86_64:
"dwg_read_file(char*, _dwg_struct*)", referenced from:
load_dwg(char*)in ccN6HUqz.o
"dwg_free(_dwg_struct*)", referenced from:
load_dwg(char*)in ccN6HUqz.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
どうすればよいかわかりません。コンパイラが不平を言うソースの問題をすべて修正し、-lredwg を使用して関連するライブラリにリンクしています (そうですか? 見逃していませんか?)。私のヘッダーファイルは機能をテストするためのもので、次のようになります。
#include "suffix.c"
#include <dwg.h>
plan floor_plan;//temporary data structure defined elsewhere for now
void
add_line(double x1, double y1, double x2, double y2)
{
line_in temp;
temp.start.x=x1;
temp.start.y=y1;
temp.end.x=x2;
temp.end.y=y2;
floor_plan.lines.push_back(temp);
std::cout<<"LINE: :"<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<std::endl;
}
void
add_circle(double x, double y, double R)
{
// Yet to do
}
void
add_text(double x, double y, char *txt)
{
// Make something with that
}
int
load_dwg(char *filename)
{
unsigned int i;
int success;
Dwg_Data dwg;
dwg.num_objects = 0;
success = dwg_read_file(filename, &dwg);
for (i = 0; i < dwg.num_objects; i++)
{
Dwg_Entity_LINE *line;
Dwg_Entity_CIRCLE *circle;
Dwg_Entity_TEXT *text;
switch (dwg.object[i].type)
{
case DWG_TYPE_LINE:
line = dwg.object[i].tio.entity->tio.LINE;
add_line(line->start.x, line->end.x, line->start.y, line->end.y);
break;
case DWG_TYPE_CIRCLE:
circle = dwg.object[i].tio.entity->tio.CIRCLE;
add_circle(circle->center.x, circle->center.y, circle->radius);
break;
case DWG_TYPE_TEXT:
text = dwg.object[i].tio.entity->tio.TEXT;
add_text(text->insertion_pt.x, text->insertion_pt.y, (char*) text->text_value);
break;
}
}
dwg_free(&dwg);
return success;
}
私は何を間違っていますか?libredwg は c で書かれていると思います。これが問題ですか?