gnu cgi (cgicc)不使用MinGW/Cygwin编译Windows上的gcc

时间:2022-08-08 01:56:33

I have to build a "proof of concept" using cgicc on Windows. But currently I am unable to build cgicc. The current release of cgicc v3.2.9 won't build neither in MinGW (gcc v4.5.0 / v3.4.5) nor Cygwin (gcc v4.3.4-3).

我必须在Windows上使用cgicc构建一个“概念证明”。但是目前我还不能建立cgicc。目前的cgicc v3.2.9版本在MinGW (gcc v4.5.0 / v3.4.5)和Cygwin (gcc v4.3.4-3)中都不会构建。

By using gcc v3.4.5 and automake in MinGW I got:

在MinGW中使用gcc v3.4.5和automake,得到:

HTMLAttributeList.cpp:51: internal compiler error: in rest_of_handle_final, at toplev.c:2067 Please submit a full bug report, with preprocessed source if appropriate.


Using gcc v4.3.4 and automake gives for Cygwin:

使用gcc v4.3.4和automake为Cygwin提供:

In file included from CgiEnvironment.cpp:36: ../cgicc/CgiEnvironment.h:52: error: explicit instantiation of 'class std::vector<cgicc::HTTPCookie, std::allocator<cgicc::HTTPCookie> >' in namespace 'cgicc' which does not enclose namespace 'std')

and for gcc v4.5.0 in MinGW:

对于MinGW中的gcc v4.5.0:

../cgicc/CgiEnvironment.h:52:33: error: explicit instantiation of 'class std::vector<cgicc::HTTPCookie>' in namespace 'cgicc' (which does not enclose namespace 'std')



I tried to ignore the Automake and Autoconf scripts. I set up Eclipse-CDT for using the apropriate compiler switches (I also tried Code::Blocks):

我试图忽略Automake和Autoconf脚本。我设置了Eclipse-CDT,用于使用专有编译器开关(我还尝试了代码::Blocks):

-DHAVE_CONFIG_H -DWIN32 -I.. -Wall -W -pedantic -g -DDLL_EXPORT -DPIC -DCGICC_EXPORTS

But again I got:

但是我有:

explicit instantiation of 'class std::vector<cgicc::HTTPCookie, std::allocator<cgicc::HTTPCookie> >' in namespace 'cgicc' (which does not enclose namespace 'std') CgiEnvironment.h /cgicc/cgicc line 52

CgiEnvironment.h:51 to line 53 contains the ifdef WIN32:

CgiEnvironment。h:51到第53行包含ifdef WIN32:

#include <string>
#include <vector>
#include <cstdlib>

namespace cgicc {
...
#ifdef WIN32
  template class CGICC_API std::vector<HTTPCookie>;
#endif
...
}

What goes wrong? Any suggestions?

什么错了吗?有什么建议吗?

2 个解决方案

#1


1  

Now I can compile cgicc. Thanks to a very good friend of mine, Vlad Lazarenko and some hours of investigation. But I have to do some major changes.

现在我可以编译cgicc了。多亏了我的好朋友弗拉德·拉扎连科和几个小时的调查。但是我必须做一些重大的改变。

My friend helped me to go on the right way by understanding the main issue. He and Vlad Lazarenko gave me a good direction to investigate the __declspec(). This is a feature of Microsoft compilers which are now supported in gcc.

我的朋友通过理解主要问题,帮助我走上了正确的道路。他和弗拉德·拉扎连科给了我一个很好的方向去调查机密文件。这是目前在gcc中支持的Microsoft编译器的特性。

During investigation I stumbled over a post with migration hints for GCC3.4.3 to GCC4.1.2. So I moved the explicit instantiation of the templates behind the declared namespace in following headers:

在调查过程中,我无意中发现了一个关于GCC3.4.3到GCC4.1.2迁移的提示。因此,我将模板的显式实例化移到了声明的名称空间后面,如下面的标题:

Cgicc.h
CgiEnvironment.h
HTMLAttributeList.h
HTMLElementList.h

Cgicc。h CgiEnvironment。h HTMLAttributeList。h HTMLElementList.h

Next I discovered a strange behaviour while checking different compiler switches and other things regarding my build environment. During investigatiopn of cgicc header files the defined -DCGICC_EXPORTS becomes sometimes undefined (expansion is shown by Eclipse CDT). So I changed CgiDefs.h from:

接下来,我在检查不同的编译器开关和关于构建环境的其他事情时发现了一个奇怪的行为。在cgicc头文件的调查表中,定义的- dcgicc_export有时会变得没有定义(扩展由Eclipse CDT显示)。所以我改变了CgiDefs。h:

// export library symbols
#ifdef CGICC_EXPORTS
#  define CGICC_API __declspec(dllexport)
#else
#  define CGICC_API __declspec(dllimport)
#endif 

to

#  define CGICC_API __declspec(dllimport)

At the end I changed the compiler switches to
-DWIN32 -DCGICC_EXPORTS -DHAVE_CONFIG_H -I.. -O0 -g3 -Wall -c -fmessage-length=0 -std=gnu++98. Most important is -std=gnu++98. Without gnu extensions __declspec() wont generate any symbols - even for a static library. I do not understand why I need that for a static library because the symbols should be in their object files which are packet into libcgicc.a.

最后,我将编译器切换到-DWIN32 -DCGICC_EXPORTS -DHAVE_CONFIG_H -I..-O0 -g3 -c -fmessage-length=0 -std=gnu++98。最重要的是化gnu + + 98。如果没有gnu扩展,__declspec()不会生成任何符号——即使是静态库。我不明白为什么我需要一个静态库,因为符号应该在它们的对象文件中,这些文件被包到libcgc .a中。

Now some further questions:

现在一些进一步的问题:

  1. Do anyone know a mechanism how CGICC_EXPORTS can became undefined without
    #undef CGICC_EXPORTS and without -UCGICC_EXPORTS?
  2. 有人知道CGICC_EXPORTS如何在没有#undef CGICC_EXPORTS和-UCGICC_EXPORTS的情况下变得没有定义的机制吗?
  3. Why I have to use gnu extensions? I thought the defaults are independend.
  4. 为什么我必须使用gnu扩展?我认为默认值是独立的。
  5. Why do I have to use __declspec(dllexport) for a static library?
  6. 为什么我必须使用__declspec(dllexport)作为静态库?
  7. Why it is not enough to use the object files of a static library? Let me ask the same in a different way: Why are no symbols found if I try to link object files of a static library?
  8. 为什么仅仅使用静态库的对象文件是不够的呢?让我以另一种方式问同样的问题:如果我尝试链接静态库的对象文件,为什么没有找到符号呢?
  9. What is the advantage/disadvantage of "implicit template instantiation and vague linkage" versus "explicit template instantiation"?
  10. “隐式模板实例化和模糊链接”与“显式模板实例化”的优缺点是什么?

#2


0  

The CGICC_API should be either defined as __declspec(dllimport) or __declspec(dllexport). It looks like that DLL_EXPORT macro that gets defined in command line should affect that, but it doesn't. My guess is that some header handling it is not included. See this and that for more information.

CGICC_API应该定义为__declspec(dllimport)或__declspec(dllexport)。看起来在命令行中定义的DLL_EXPORT宏应该会影响它,但它不会。我的猜测是一些头处理它不包括。有关更多信息,请参阅这个和那个。

#1


1  

Now I can compile cgicc. Thanks to a very good friend of mine, Vlad Lazarenko and some hours of investigation. But I have to do some major changes.

现在我可以编译cgicc了。多亏了我的好朋友弗拉德·拉扎连科和几个小时的调查。但是我必须做一些重大的改变。

My friend helped me to go on the right way by understanding the main issue. He and Vlad Lazarenko gave me a good direction to investigate the __declspec(). This is a feature of Microsoft compilers which are now supported in gcc.

我的朋友通过理解主要问题,帮助我走上了正确的道路。他和弗拉德·拉扎连科给了我一个很好的方向去调查机密文件。这是目前在gcc中支持的Microsoft编译器的特性。

During investigation I stumbled over a post with migration hints for GCC3.4.3 to GCC4.1.2. So I moved the explicit instantiation of the templates behind the declared namespace in following headers:

在调查过程中,我无意中发现了一个关于GCC3.4.3到GCC4.1.2迁移的提示。因此,我将模板的显式实例化移到了声明的名称空间后面,如下面的标题:

Cgicc.h
CgiEnvironment.h
HTMLAttributeList.h
HTMLElementList.h

Cgicc。h CgiEnvironment。h HTMLAttributeList。h HTMLElementList.h

Next I discovered a strange behaviour while checking different compiler switches and other things regarding my build environment. During investigatiopn of cgicc header files the defined -DCGICC_EXPORTS becomes sometimes undefined (expansion is shown by Eclipse CDT). So I changed CgiDefs.h from:

接下来,我在检查不同的编译器开关和关于构建环境的其他事情时发现了一个奇怪的行为。在cgicc头文件的调查表中,定义的- dcgicc_export有时会变得没有定义(扩展由Eclipse CDT显示)。所以我改变了CgiDefs。h:

// export library symbols
#ifdef CGICC_EXPORTS
#  define CGICC_API __declspec(dllexport)
#else
#  define CGICC_API __declspec(dllimport)
#endif 

to

#  define CGICC_API __declspec(dllimport)

At the end I changed the compiler switches to
-DWIN32 -DCGICC_EXPORTS -DHAVE_CONFIG_H -I.. -O0 -g3 -Wall -c -fmessage-length=0 -std=gnu++98. Most important is -std=gnu++98. Without gnu extensions __declspec() wont generate any symbols - even for a static library. I do not understand why I need that for a static library because the symbols should be in their object files which are packet into libcgicc.a.

最后,我将编译器切换到-DWIN32 -DCGICC_EXPORTS -DHAVE_CONFIG_H -I..-O0 -g3 -c -fmessage-length=0 -std=gnu++98。最重要的是化gnu + + 98。如果没有gnu扩展,__declspec()不会生成任何符号——即使是静态库。我不明白为什么我需要一个静态库,因为符号应该在它们的对象文件中,这些文件被包到libcgc .a中。

Now some further questions:

现在一些进一步的问题:

  1. Do anyone know a mechanism how CGICC_EXPORTS can became undefined without
    #undef CGICC_EXPORTS and without -UCGICC_EXPORTS?
  2. 有人知道CGICC_EXPORTS如何在没有#undef CGICC_EXPORTS和-UCGICC_EXPORTS的情况下变得没有定义的机制吗?
  3. Why I have to use gnu extensions? I thought the defaults are independend.
  4. 为什么我必须使用gnu扩展?我认为默认值是独立的。
  5. Why do I have to use __declspec(dllexport) for a static library?
  6. 为什么我必须使用__declspec(dllexport)作为静态库?
  7. Why it is not enough to use the object files of a static library? Let me ask the same in a different way: Why are no symbols found if I try to link object files of a static library?
  8. 为什么仅仅使用静态库的对象文件是不够的呢?让我以另一种方式问同样的问题:如果我尝试链接静态库的对象文件,为什么没有找到符号呢?
  9. What is the advantage/disadvantage of "implicit template instantiation and vague linkage" versus "explicit template instantiation"?
  10. “隐式模板实例化和模糊链接”与“显式模板实例化”的优缺点是什么?

#2


0  

The CGICC_API should be either defined as __declspec(dllimport) or __declspec(dllexport). It looks like that DLL_EXPORT macro that gets defined in command line should affect that, but it doesn't. My guess is that some header handling it is not included. See this and that for more information.

CGICC_API应该定义为__declspec(dllimport)或__declspec(dllexport)。看起来在命令行中定义的DLL_EXPORT宏应该会影响它,但它不会。我的猜测是一些头处理它不包括。有关更多信息,请参阅这个和那个。