Skip to content

Commit

Permalink
docs: Update ZMQ for module directory structure. (#2191)
Browse files Browse the repository at this point in the history
* docs: Update ZMQ for module directory structure.

Signed-off-by: Mike Johanson <michael.johanson@intel.com>
  • Loading branch information
rsdmike authored and michaelestrin committed Dec 12, 2019
1 parent 1079919 commit 32c2c55
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ZMQWindows.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Setting up ZMQ to build on Windows

> Last updated Nov 2019 to be reworked for module directory structure.
0. Ensure that you've followed the steps leading up to this on the [README.md](README.md), this includes any dependenices. Clone this repository into the `%GOPATH%\src\github.com\edgexfoundry\` directory, using `git clone https://github.com/edgexfoundry/edgex-go.git %GOPATH%\src\github.com\edgexfoundry\edgex-go`.

1. Download & install the TDM-GCC from this URL: http://tdm-gcc.tdragon.net/download
Expand All @@ -10,25 +12,32 @@

3.a. Extract the contents of the downloaded zip file anywhere you prefer.

3.b. Copy the `libsodium.dll` and `libzmq-v120-mt-4_x_x.dll` files from step 3 into `%GOPATH%\src\github.com\pebbe\zmq4\usr\local\lib`; create all of the directories if you need to. Rename `libzmq-v120-mt-4_x_x.dll` to `libzmq.dll`, so that gcc can link and find `-lzmq`. If this is not done, errors like this may occur: `C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe:cannot find -lzmq`
3.b. Copy the `libsodium.dll` and `libzmq-v120-mt-4_x_x.dll` files from step 3 into `%GOPATH%\pkg\mod\github.com\pebbe\zmq4@v1.0.0\lib`; create the lib directory as needed. Rename `libzmq-v120-mt-4_x_x.dll` to `libzmq.dll`, so that gcc can link and find `-lzmq`. If this is not done, errors like this may occur: `C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe:cannot find -lzmq`

> Note: As of Nov 2019, ZMQ 4.3.3 does not work and results in an error: https://github.com/pebbe/zmq4/issues/152/. 4.3.2 is recommended and tested on Win 10:
https://ci.appveyor.com/project/zeromq/libzmq/builds/25882500/job/s2yhbnjrdouq5qnm/artifacts
and
https://github.com/zeromq/libzmq/tree/a84ffa12b2eb3569ced199660bac5ad128bff1f0.

3. In any directory you prefer, clone the source of ZMQ that matches the version/commit you downloaded from AppVeyor: `git clone https://github.com/zeromq/libzmq.git`.
4. In any directory you prefer, clone the source of ZMQ `git clone https://github.com/zeromq/libzmq.git` and ensure it matches the version/commit you downloaded from AppVeyor (i.e `git reset --hard a84ffa12`).

4. Copy over the `include` directory from the source downloaded in step 3 to `%GOPATH%\src\github.com\pebbe\zmq4\usr\local\include`, ensuring that any necessary parent directories that don't exist are created.
5. Copy over the `include` directory from the source downloaded in step 3 to `%GOPATH%\pkg\mod\github.com\pebbe\zmq4@v1.0.0\`.

5. Set the following environment variables (run this in PowerShell):
6. Set the following environment variables (run this in PowerShell):

```
$Env:CGO_CFLAGS="-I$Env:GOPATH\src\github.com\pebbe\zmq4\usr\local\include"
$Env:CGO_LDFLAGS="-L$Env:GOPATH\src\github.com\pebbe\zmq4\usr\local\lib"
$Env:CGO_CFLAGS="-I$Env:GOPATH\pkg\mod\github.com\pebbe\zmq4@v1.0.0\include"
$Env:CGO_LDFLAGS="-L$Env:GOPATH\pkg\mod\github.com\pebbe\zmq4@v1.0.0\lib"
```

After setting those, running `go get -v -x github.com/pebbe/zmq4` should succeed. If it fails, it most likely due to the `.h` files or `dll`s existing in a directory that doesnt match your `CGO_` environment variables. It may also fail due to the same error as before (see step 3.b) - try downloading the artifact from a different build on the [AppVeyor builds site](https://ci.appveyor.com/project/zeromq/libzmq).

5. Next, navigate to `$Env:GOPATH\src\github.com\edgexfoundry\edgex-go\cmd\core-data`. *If you didn't acquire dependencies previously, run `go get -v` to acquire all dependencies*. Run `go build -v`. If it complains about not finding zmq.h from auth.go, double check the CGO_ environment variables by running `go env`.
> It is recommended to set these environment variables in your System or IDE so that you do not need to set them in every terminal session. This especially required if you wish to debug services that depend on ZMQ.
7. Next, navigate to `$Env:GOPATH\src\github.com\edgexfoundry\edgex-go\cmd\core-data`. *If you didn't acquire dependencies previously, run `go get -v` to acquire all dependencies*. Run `go build -v`. If it complains about not finding zmq.h from auth.go, double check the CGO_ environment variables by running `go env`.

6. There should now be a `core-data.exe` file in your directory. The last step is to ensure that a copy of the DLL's `libsodium.dll` and `libzmq-v120-mt-4_x_x.dll` (yes, this one, not with the rename we did earlier) is in the same directory as your `.exe`.
8. There should now be a `core-data.exe` file in your directory. The last step is to ensure that a copy of the DLL's `libsodium.dll` and `libzmq-v120-mt-4_x_x.dll` (yes, this one, not with the rename we did earlier) is in the same directory as your `.exe`. You will need to copy these .dlls in manually.

7. Run `.\core-data.exe`.
9. Run `.\core-data.exe`.

> If you get a segfault, try setting `$Env:GOCACHE="off"` and rerun the build command from step 5

0 comments on commit 32c2c55

Please sign in to comment.