gpt4 book ai didi

c++ - 如何编译flex代码以获得动态库?

转载 作者:太空宇宙 更新时间:2023-11-04 02:52:51 25 4
gpt4 key购买 nike

我想编译我的 flex scanner.l 以便从我的 C/C++ 项目中调用一个动态库。正确的做法是什么?我能否在不同线程中从我的 C/C++ 程序同时调用扫描器?

最佳答案

(评论中回答的问题。参见 Question with no answers, but issue solved in the comments (or extended in chat) )

@Josh 写道:

The same way you make any other dynamic library with your compiler.

Have your other program call the method(s) defined in lex.yy.c. When you go to compile, tell gcc to compile both your primary program and lex.yy.c. Making it a dynamic library seems a bit overkill.

Flex can generate a re-entrant parser (safe for multi threaded applications):
Flex manual

And if you just want to learn how to create a shared library with gcc, a quick google search should turn up plenty of good results. If you run into specific issues you can be helped further from there.

关于c++ - 如何编译flex代码以获得动态库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20405884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com