Giter VIP home page Giter VIP logo

Comments (6)

jinjin123 avatar jinjin123 commented on August 13, 2024 1

I was install these tool package in ubuntu20.04 and mac air, but still not work.... #6

from go-scrap.

jcloutz avatar jcloutz commented on August 13, 2024 1

@joalzamora I ran into this issue as well, and it was because I had to build the cargo project for the module, not the normal go path src directory. After I installed it for the module I had to go here to build the package and it ran correctly:

%GOPATH%\pkg\mod\github.com\cretz\[email protected]\scrap-sys

from go-scrap.

cretz avatar cretz commented on August 13, 2024

Did you follow the readme directions exactly, including running the Rust project build first?

from go-scrap.

joalzamora avatar joalzamora commented on August 13, 2024

The steps I have taken are the following:

go get -d github.com/cretz/go-scrap

cd scrap-sys
cargo build --release

Finished release [optimized] target(s) in 0.04s

cd ..
rustup default stable-x86_64-pc-windows-gnu
info: using existing install for 'stable-x86_64-pc-windows-gnu'
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'

stable-x86_64-pc-windows-gnu unchanged - rustc 1.40.0 (73528e339 2019-12-16)

go run ./example/screenshot

C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lscrap_sys
collect2.exe: error: ld returned 1 exit status

Will I be skipping any steps?

from go-scrap.

cretz avatar cretz commented on August 13, 2024

Hrmm, haven't looked at this project in a bit, but maybe go build instead of go run. Otherwise, there's something not putting that library on the library path. Not sure when I'll be able to debug otherwise.

from go-scrap.

ld269440877 avatar ld269440877 commented on August 13, 2024

x86_64-w64-mingw32/bin/ld.exe: cannot find -lscrap_sys #4

Section 1: environment

  • windows 10
  • x86_64-w64-mingw32 or x86_64_Cygwin

Section 2: abstract:

  1. gcc -shared -->create shared library:
  • linux

    gcc -shared -o libmymath.so sub.o add.o

  • windows

    gcc -shared -o libmymath.dll add.o sub.o

Section 3: step by step

  1. 首先我们将源代码编译为目标文件:
    gcc -fPIC -c add.c sub.c
    执行完毕后会生产add.o和sub.o文件

  2. 然后使用gcc的-shared选项来表明创建一个共享库:

  • linux
    
      gcc -shared -o libmymath.so sub.o add.o
    
  • windows
    
      gcc -shared -o libmymath.dll add.o sub.o
    

    执行完后,会创建一个libmymath.so动态链接库文件, so是 Shared Object 的缩写,即可以共享的目标文件。

  1. 用动态库编译主程序
    gcc -o main -lmymath -L./ main.c # relative path
    or
    gcc -Wall -o test main.c -lmymath -Lf:/gitee/play-ground/c.xxxxxx/shared_lib/libs # absolute path

  2. 执行
    4.1 windows and linux 加动态库路径到环境变量
    powershell:
    $env:PATH="$env:PATH;./so_path"
    cmd:
    set PATH=%PATH%;C:\your\path\here
    shell:
    export PATH="$PATH:./so_path"

    4.2 添加动态库路径后就可以正常执行exe
    如果每添加动态库路径到环境变量执行exe没有任何提示或找不到so
    .\test.exe

Section 4: Reference

C语言 共享库(动态库)制作

cygwin : Linker doesn't find shared library - Stack Overflow

from go-scrap.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.