Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > LNK2019 error - почему?


Автор: GrAndrey 16.9.2004, 22:40
В моем приложении нужно использовать регулярные выражения. Выбрал Greta (http://www.research.microsoft.com/projects/greta/), которая показалась мне гораздо проще Regexp++ boost. PCRE++ вообще, похоже, для Гну и подружить их с седьмой студией - опыт нужно иметь smile.gif
Только, жаль, что Greta вызывает ошибки в линкере примерно такого содержания:
Код

Linking...
diplom.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl regex::detail::DEFAULT_BLOCK_SIZE(void)" (?DEFAULT_BLOCK_SIZE@detail@regex@@YAIXZ) referenced in function "protected: __thiscall regex::detail::basic_rpattern_base_impl<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::const_iterator>::basic_rpattern_base_impl<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::const_iterator>(enum regex::REGEX_FLAGS,enum regex::REGEX_MODE,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?

<<< конкретно поснипал >>>

$basic_rpattern_base_impl@Vconst_iterator@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@12@AAU?$match_param@Vconst_iterator@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@12@AAV?$vector@V?$backref_tag@Vconst_iterator@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@regex@@V?$allocator@V?$backref_tag@Vconst_iterator@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@reg
ex@@@std@@@std@@_N@Z)
Release/diplom.exe : fatal error LNK1120: 5 unresolved externals


Опции по умолчанию, разве только в линкере увеличил стек, но это вообще никак на ситуацию не влияет.
Попробуйте, пожалуйста, откомпилить. В чем дело? Какие опции нужно поменять? Плиз, страдаю sad.gif
В крайнем случае, посоветуйте чем можно другим обойтись.

Автор: mr.DUDA 17.9.2004, 09:11
Вместе с заголовочными файлами Greta поставляются Lib-ы ? Если да, то их нужно подключить в настройках проекта (Project settings / Linker).

Автор: GrAndrey 17.9.2004, 16:07
Нет, либы не поставляются. Пробую компилить сами библиотеки, а также сэмпл из гида - та же проблема. bcс тоже ругается. Видно, дело в ключах компилятора. С дефолтными не проходит sad.gif

Автор: Step 19.9.2004, 14:50
Выложи хеадер библиотеки сюда и я думаю уважаемый mr.DUDA тебе поможет



Добавлено @ 14:51
smile.gif

Автор: GrAndrey 19.9.2004, 20:59
Вообще-то, там 4 хидера общей массой в 134 кб. Только их заголовочная часть, думаю, скажет не слишком много, но хто знает? Лучше, конечно, скачать и посмотреть: 100кб, страничка http://www.research.microsoft.com/projects/greta/ (прямо на файл не могу, там глупый скрипт с соглашением, но найти очень легко на этой странице).

Код

//+---------------------------------------------------------------------------
//  Copyright ( C ) Microsoft, 1994 - 2002.
//  File:       regexpr2.h
//  Contents:   classes for regular expression pattern matching a-la perl
//  Classes:    basic_rpattern_base
//
//  Functions:  rpattern::match
//              rpattern::substitute
//              match_results::cbackrefs
//              match_results::backref
//              match_results::all_backrefs
//              match_results::backref_str
//
//  Author:     Eric Niebler ( [email protected] )
//----------------------------------------------------------------------------

#ifndef REGEXPR_H
#define REGEXPR_H

#ifdef _MSC_VER
 // warning C4189: local variable is initialized but not referenced
 // warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
 // warning C4702: unreachable code
 // warning C4710: function 'blah' not inlined
 // warning C4786: identifier was truncated to '255' characters in the debug information
# pragma warning( push )
# pragma warning( disable : 4189 4290 4702 4710 4786 )
# define REGEX_SEH_STACK_OVERFLOW 0xC00000FDL
# if 1200 < _MSC_VER
# include <malloc.h> // for _resetstkoflw
# else
 extern "C" int __cdecl _resetstkoflw(void);
# endif
 extern "C" unsigned long __cdecl _exception_code(void);
#endif

#include <list>
#include <iosfwd>
#include <string>
#include <vector>
#include <memory>
#include <cwctype>
#include "syntax2.h"
#include "restack.h"
...

//+---------------------------------------------------------------------------
//  File:       restack.h
//  Functions:  a quick-'n'-dirty, type-unsafe stack used by the iterative
//              regular expression algorithm
//  Notes:      Care must be taken when using this stack. You must pop off
//              the correct type of object, otherwise you get garbage. Also,
//              if you push anything that has a non-trivial destructor, then
//              be sure to explicitely pop everything off the stack and don't
//              use the unsafe_long_jump method.
//----------------------------------------------------------------------------

#ifndef HETERO_STACK_H
#define HETERO_STACK_H

#include <string>
#include <utility>
#include <typeinfo>
#include <stdexcept>
#include <functional>
...

//+---------------------------------------------------------------------------
//  File:       syntax2.h
//  Contents:   syntax modules for regexpr
//  Classes:    perl_syntax, posix_syntax
//----------------------------------------------------------------------------

#ifndef SYNTAX_H
#define SYNTAX_H

#ifdef _MSC_VER
#pragma warning( push )
// warning C4786: identifier was truncated to '255' characters in the debug information
#pragma warning( disable : 4786 )
#endif

#include <map>
#include <iosfwd>
#include <string>
#include <cctype>
#include <cwctype>
#include <cassert>
#include <iterator>
#include <stdexcept>



В общем, как обнаружилось, все компилируется, пока не использована какая-либо функция из библиотеки. Вообще, сейчас перепробовал почти все регекспы - все достают меня ошибками линкера. Даже когда подключал предкомпилированные libы. Может вижуал криво стоит? Или мне нужно что-то почитать о линкаже?

Автор: Гость_GrAndrey 21.9.2004, 13:39
Как оказалось, нужно было отключить опцию "use precompiled header". С ума сойти. Ни в жизнь бы не догадался.

Автор: DENNN 21.9.2004, 14:39
Цитата
Как оказалось, нужно было отключить опцию "use precompiled header".

Или элементарно нажать кнопочку "Rebuild All".


Автор: Guest 21.9.2004, 17:37
Дык я вроде чистил проект. Результат разве не тот-же должен быть?

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)