3

My problem is:

I have compiled LuaJit with VisualStudio and its genereated a .Obj file, a dll and .lib file. i just want to link the .obj file in my win32 application to generate a single EXE file. If its possible,i still need to add the Lua headers?

Thanks anyway.

1
  • Project + Properties, General, change Configuration type from .dll to .lib. And add this .lib to your main EXE project's Additional Dependencies setting. This doesn't necessarily always work. Aug 17, 2011 at 19:27

2 Answers 2

1

Use the header file to define LuaJit symbols for your code that deals with Lua.

To link you only need the lib and dll. Add the lib file to your link dependencies under Project Properties > Linker > Input. Put the DLL next to your EXE when you run.

5
  • There is no way to me not use the dll file? Aug 17, 2011 at 19:06
  • Sure, put the source files for LuaJit in your project, or add the OBJ as the additional dependency for the linker. Just be careful that you don't link to another project that includes the same LuaJit library as a DLL.
    – totowtwo
    Aug 17, 2011 at 19:09
  • i need to add every OBJ file to the Addtional dependency? When i talk every i'm talking about all OBJ files generated from every source code file.Btw, in the gcc compiler it can be done different? Aug 17, 2011 at 19:27
  • Eh sorry, Read jdv's answer. All of these obj files get compiled into one library. If that library is a dynamically linked library, you get a pair of files (LIB+DLL). If that library is statically linked library, you get a single LIB file. You want to change your LuaJit build to create a statically linked library. Then add the static LIB to your linking depdencies.
    – totowtwo
    Aug 17, 2011 at 19:51
  • Change the project to a static LIB under Project Properties > Configuration Properties > "Configuration Type" : Static Library (.lib)
    – totowtwo
    Aug 17, 2011 at 19:53
-1

You need to make the project produce a .lib file containing the code (instead of in addition to the dll) and link that. It could be that you can by switching the project setting (look for one labelled lib, or static). Otherwise, you'll have to modify the project settings. (set output type to lib rather than dll).

I never tried linking a .obj file directly, it might be possible. Lib files are more standard.

2
  • No, no, no, no, no! A hundred times NO. That is not the question OP asked, and it's not the question i'm tearing my hair out over right now.
    – Owl
    Jun 29, 2017 at 13:13
  • @Owl, narrowly speaking, you are correct that a .lib file is not what the OP asked regarding .obj files. But a static .lib file is merely an archive collection of .obj files internally, so .lib (as opposed to .DLL, resembling an .EXE) is only one small step removed from .obj files. On some OSes/compiler-linker-toolchains, a multi-pass linker is more forgiving of .lib's order of appearance on linker command line (or the librarian's command line that archived the .obj files into a single .lib file) than a single-pass of a linker is for .obj files mentioned overtly on the linker's command line. Mar 27, 2018 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.