lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sorry, I misunderstood that you wanted me to do a test on some new, simple files. I don’t know much about “toolchains” so I doubt I’ve got it set up right.

 

I made a ‘static’ folder in my ‘test’ workspace folder. I unzipped lua-5.1.4_Win64_mingw4_lib.zip, iup-3.30_Win64_mingw6_lib.zip, and iup-3.30-Lua51_Win64_mingw6_lib.zip into it. All the .a files are in ‘static’ and the .h files are in the ‘include’ subfolder.

 

I made c_cpp_properties.json like you said, but used '"compilerPath": "C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe"' because I want to test embedding Lua in C. Since I’m using Lua 5.1, I changed -llua54 to -llua, and -liuplua54 to -liuplua51. Did I need the dynamic link section if I’m not using that? I left that out.

 

What should I put into the files to test? I tried the tutorial here: https://sodocumentation.net/lua/topic/671/introduction-to-lua-c-api but it didn’t work. For ‘dofile’, I used ‘script.lua’, which contains the line ‘print("Hello, World from File")’. I got a red squiggle under ‘return EXIT_SUCCESS;’ so I tried ‘return 0;’ to appease VSCode. The build/debug said it couldn’t find ‘-llua’.

 

> 4. if you are using static linking, in `src/main.cpp`, don't forget to add `iuplua_open`,`iupcontrolslua_open`, etc, into the `package.preload` table so that Lua code have access to IUP.

 

  I don’t know about `package.preload` tables and the app I’m working on didn’t use it in the C file. Is there something simple I can copy and paste just to see if my toolchain is working?

 

 

 

From: nerditation
Sent: Saturday, October 23, 2021 4:38 AM
To: lua-l@lists.lua.org
Subject: Re: I Can't Get Lua 5.1 and IUP 3.30 to Work With VSCode and GCC on Windows 10 x64

 

On 2021/10/17 5:00, Kaz wrote:

>> [...] I'm not sure I understand your problem properly, what do you mean by "C script" and "calls the header files"?[...]

>

>  

>

> Most of the app’s source files are Lua files, but one is .c. The file written in C has a bunch of “#include” statements like #include “iup.h” and it contains some global variables. The actual app code, beyond setting up includes and some globals, is in the Lua files.

>

>

 

if the app contains only 1 single C source file, it should be really easy to set up the toolchain and editor.

 

please refer to the example in my previous post.

 

feel free to reach me off list if you have trouble understanding the instructions.

 

>

> I’ve since downloaded and installed the .h header files for Lua 5.1 (the app uses this version and the code uses “getn” a lot, which was depreciated in later versions of Lua), IUP, CD, and IM like in the Makefile included in the app’s source files, added the “include” and “Lua51” directories to the “path” section of Environment Variables, but VSCode still can’t find them.

>

>

 

you need the correct development packages to be able to build, not just the 'header files'. also you need to

configure the tools correctly, including vscode the editor, not only the Makefile.

 

>

>> [..] what are you trying to debug, your app's source code (in C/C++) or the Lua code that run inside your host app?

>

> VSCode [...]

>

> I  don’t know which one I’m supposed to debug. I’m just trying to get VSCode to do something right and find the .h files. I tried using debug on the C file, but that didn’t work. I tried running the app’s main Lua file with the iuplua interpreter but that gives me errors too. I tried to compile, but that doesn’t work. I tried using the app’s Makefile after making some adjustments (the folder structures of the library files I downloaded weren’t the same. There were no folders called “lib”), but nothing can find the .h files.

>

 

you can use vscode (togother with gdb from mingw toolchain) to debug C/C++ code, but you need to have debugging

functionality built into your app via Lua debug API in order to debug Lua code.

 

a correct Makefile will help you build the program, but, AFAIK, vscode still need to be configured manually to

be able to use the debugger integrated within vscode.

 

>

>> [...] if your app contains native code, you should use the library packages, either static or dynamic, but not the binary ones. [..]

>

> The C file contains #include <windows.h>. Does that mean it contains “native code”?

>

 

by native code, I simply mean a program with C/C++ source files (instead of pure Lua files).