Re: Using D libraries with SDL. Error: "Cannot find module protobuf'

2024-08-24 Thread Nicol Farran Terra via Digitalmars-d-learn

On Saturday, 24 August 2024 at 06:35:50 UTC, IchorDev wrote:
On Saturday, 24 August 2024 at 00:24:12 UTC, Nicol Farran Terra 
wrote:
I am not sure if this expected behavior, but importing this in 
my app.d does not work. I get an error about a missing import.


You are importing `google.protobuf`, right?
Providing the app.d would be helpful, or at least a snippet of 
it with the import that’s giving you the ‘error’—presumably a 
compiler error?


I ran to my 'root' where my dub.sdl was, ran the build for the 
library which worked, but when I went back to my file, I get 
the same behavior. I am not sure what to make of this.


Could you please elaborate about what this means? It’s a bit 
confusing.


No, I am just importing 'protobuf'. Also  the app is literally 
the base app when you run dub.init.

Here is a more exact error.
app.d(2): Error: unable to read module `protobuf`
app.d(2):Expected 'google/protobuf.d' or 
'google/protobuf/package.d' in one of the following import paths:

import path[0] = /usr/include/dlang/dmd



Also, I tried with both google.protobuf and just protobuf. Same 
error. Although I do remember I got something interesting when 
trying to build a subproject of this one (it wasnt there for some 
reason)

Uhh, just 'root'. Where my dub.sdl is?
It is not overall project root, that is where my Package.swift 
files. It is in my Sources/source (yes because Dub does that by 
default + app.d) and in Sources is where my dub.sdl.
If you go to where my folder location is, and run dub build. It 
'works' fine if you run 'dub build'. Although only if you just 
import anything in std. If you try to import protobuf in the 
app.d, it just wont work. Here is that error.

source/app.d(2,8): Error: unable to read module `protobuf`
source/app.d(2,8):Expected 'protobuf.d' or 
'protobuf/package.d' in one of the following import paths:

import path[0] = source/
import path[1] = 
../../../../.dub/packages/protobuf/0.6.2/protobuf/src/

import path[2] = /usr/include/dlang/dmd
Error /usr/bin/dmd failed with exit code 1.



Re: Using D libraries with SDL. Error: "Cannot find module protobuf'

2024-08-24 Thread IchorDev via Digitalmars-d-learn
On Saturday, 24 August 2024 at 11:34:18 UTC, Nicol Farran Terra 
wrote:

You are importing `google.protobuf`, right?
Providing the app.d would be helpful, or at least a snippet of 
it with the import that’s giving you the ‘error’—presumably a 
compiler error?



No, I am just importing 'protobuf'.


Well, the package path is `google.protobuf`. If you import 
`protobuf` then you are telling the compiler to import something 
that does not exist, so naturally that gives you this error:


If you try to import protobuf in the app.d, it just wont work. 
Here is that error.

source/app.d(2,8): Error: unable to read module `protobuf`
source/app.d(2,8):Expected 'protobuf.d' or 
'protobuf/package.d' in one of the following import paths:

import path[0] = source/
import path[1] = 
../../../../.dub/packages/protobuf/0.6.2/protobuf/src/

import path[2] = /usr/include/dlang/dmd
Error /usr/bin/dmd failed with exit code 1.


Also, I tried with both google.protobuf and just protobuf. Same 
error.


So, how does this error look when you `import google.protobuf`?

dub is telling you the file path:
`../../../../.dub/packages/protobuf/0.6.2/protobuf/src/` ~ 
(`protobuf.d` or `protobuf/package.d`).
If you look, you will see that there’s no such file or folder, 
but [there should be a google folder & a protobuf folder inside 
it](https://github.com/dcarp/protobuf-d/blob/master/src/google/protobuf/package.d). The folder structure defines how the modules & packages are named (i.e. `google/protobuf/package.d` => `import google.protobuf`), so in the future you can check the folder structure if you have this issue anywhere else, since sometimes dub packages just don’t say how they should be imported.



Also the app is literally the base app when you run dub.init.
Here is a more exact error.
app.d(2): Error: unable to read module `protobuf`
app.d(2):Expected 'google/protobuf.d' or 
'google/protobuf/package.d' in one of the following import 
paths:

import path[0] = /usr/include/dlang/dmd


Are you just running dmd on `app.d` from inside `source` this 
time? If not then why are all of your project’s import paths 
missing??


Although I do remember I got something interesting when trying 
to build a subproject of this one (it wasnt there for some 
reason)


Did you try `dub build protobuf:protoc-gen-d`?


Uhh, just 'root'. Where my dub.sdl is?


Yes, that’s the root directory of your dub package.


Re: Using D libraries with SDL. Error: "Cannot find module protobuf'

2024-08-24 Thread Nicol Farran Terra via Digitalmars-d-learn

On Saturday, 24 August 2024 at 12:11:03 UTC, IchorDev wrote:

snip



Okay, yeah now I see my problem sort of. So now it at least 
builds, but it wont compile with dmd app.d.
Says basically the same thing before where it cannot find the 
module. Maybe I am supposed to link it? I am so used to doing 
single file projects, I just did dmd app.d to see if it would 
work.


But yes, good news is in dub.sdl root, it builds. So I think I am 
good? Maybe I am just missing something in the compiler use lol. 
I think I can assume if I can build with my SDL at my dub.sdl 
root, it should be fine. I think. Idk




Re: Using D libraries with SDL. Error: "Cannot find module protobuf'

2024-08-24 Thread IchorDev via Digitalmars-d-learn
On Saturday, 24 August 2024 at 12:24:04 UTC, Nicol Farran Terra 
wrote:

On Saturday, 24 August 2024 at 12:11:03 UTC, IchorDev wrote:

snip



Okay, yeah now I see my problem sort of. So now it at least 
builds, but it wont compile with dmd app.d.
Says basically the same thing before where it cannot find the 
module. Maybe I am supposed to link it? I am so used to doing 
single file projects, I just did dmd app.d to see if it would 
work.


But yes, good news is in dub.sdl root, it builds. So I think I 
am good? Maybe I am just missing something in the compiler use 
lol. I think I can assume if I can build with my SDL at my 
dub.sdl root, it should be fine. I think. Idk


If you build directly with dmd you will have to specify 
everything you build against manually, including your 
dependencies’ import directories. However, there’s no reason to 
do that since dub does this for you (and caches builds too). If 
you want to know what commands dub is running to build your 
project then you can use `dub -v --force`.


Re: Using D libraries with SDL. Error: "Cannot find module protobuf'

2024-08-24 Thread Nicol Farran Terra via Digitalmars-d-learn

On Saturday, 24 August 2024 at 12:29:41 UTC, IchorDev wrote:
On Saturday, 24 August 2024 at 12:24:04 UTC, Nicol Farran Terra 
wrote:

On Saturday, 24 August 2024 at 12:11:03 UTC, IchorDev wrote:

snip


snip2


That isvery helpful. So sort of like Swift, running the 
'build' command will just go through my source tree and just make 
sure everything links + builds for compile or am I missing 
something?
So basically, unless I want to use the compiler -f flag, I should 
probably just use dub build going forward to see if my work 
compiles.





Re: Using D libraries with SDL. Error: "Cannot find module protobuf'

2024-08-24 Thread IchorDev via Digitalmars-d-learn
On Saturday, 24 August 2024 at 12:35:03 UTC, Nicol Farran Terra 
wrote:

On Saturday, 24 August 2024 at 12:29:41 UTC, IchorDev wrote:
On Saturday, 24 August 2024 at 12:24:04 UTC, Nicol Farran 
Terra wrote:

On Saturday, 24 August 2024 at 12:11:03 UTC, IchorDev wrote:

snip


snip2


That isvery helpful. So sort of like Swift, running the 
'build' command will just go through my source tree and just 
make sure everything links + builds for compile or am I missing 
something?


You’re spot on.

So basically, unless I want to use the compiler -f flag, I 
should probably just use dub build going forward to see if my 
work compiles.


You could add `dflags "-f"` to your dub.sdl if you want the 
compiler to be passed `-f`: 
https://dub.pm/dub-reference/build_settings/#dflags
Keep in mind that some flags are compiler-specific, so if you 
want to try LDC2 or GDC you might need to create 
compiler-specific variations:

```sdl
dflags "-example" platform="dmd"
dflags "-example" platform="ldc"
dflags "--example" platform="gdc"
```

Good luck!