首页 \ 问答 \ 在Cygwin64上编译cgo lib:“ld:找不到-lmingw32”(Compile cgo lib on Cygwin64: “ld: cannot find -lmingw32”)

在Cygwin64上编译cgo lib:“ld:找不到-lmingw32”(Compile cgo lib on Cygwin64: “ld: cannot find -lmingw32”)

我正在尝试在Windows上使用cgo库,即github.com/mattn/go-sqlite3

我使用Cygwin64并安装了所有“开发”软件包,因此可以使用gcc。

但是运行go get github.com/mattn/go-sqlite3导致:

/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32

如果我在Cygwin安装程序中搜索“mingwex”和“mingw32”,我没有得到任何结果。 我在寻找错误的名称还是在64位系统上没有?

或者有更好的方法在Windows上使用该库?


请注意,README声明了这一点

但是,如果您使用go install github.com/mattn/go-sqlite3安装go-sqlite3,则不再需要gcc来构建您的应用程序

但如果我使用go install我会收到相同的错误消息。

$ go version
go version go1.6.2 windows/amd64

I'm trying to use a cgo library on Windows, namely github.com/mattn/go-sqlite3

I use Cygwin64 and installed with all "Development" packages, so gcc is availabe.

But running go get github.com/mattn/go-sqlite3 results in:

/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingwex
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lmingw32

If I search for "mingwex" and "mingw32" in the Cygwin installer, I get no results. Am I looking for the wrong names or are they not available on 64 bit systems?

Or is there a better way to use the library on Windows?


Note that the README states that

However, if you install go-sqlite3 with go install github.com/mattn/go-sqlite3, you don't need gcc to build your app anymore

but I get the same error message if I use go install.

$ go version
go version go1.6.2 windows/amd64

原文:https://stackoverflow.com/questions/37497354
更新时间:2023-09-09 21:09

最满意答案

你不要覆盖你的模拟

mockCrypto = CryptoManager.getCrypto();

经测试

@Test(expected=RuntimeException.class)
    public void testdecrpyMcpDataExceptions() throws Exception {
        Crypto mockCrypto = mock(Crypto.class);

        doThrow(new RuntimeException()).when(mockCrypto).closeSession();
        mockCrypto.closeSession();

    }

工作正常。


don't you overwrite your mock at

mockCrypto = CryptoManager.getCrypto();

Tested

@Test(expected=RuntimeException.class)
    public void testdecrpyMcpDataExceptions() throws Exception {
        Crypto mockCrypto = mock(Crypto.class);

        doThrow(new RuntimeException()).when(mockCrypto).closeSession();
        mockCrypto.closeSession();

    }

works fine.

相关问答

更多
  • 是您的主类创建其依赖项的实例(实现您提到的那些接口)? 如果可能,您最好更改主类以遵循依赖注入模式。 然后,您将通过构造函数或通过setter为我们的主类提供其依赖项。 这些依赖项可以是用于测试的模拟或生产代码中的真实实现。 稍微修改了guilhermerama的例子。 YourMainClass yourMain = new YourMainClass(anInterfaceMock); Is it your main class that creates the instances of its de ...
  • 你对模拟的假设是不正确的。 当您的测试代码实例化新对象( new RequestWrapper() )时,不使用使用Mockito.mock()创建的Mockito.mock() (除非您使用例如Powermock模拟构造函数,但这是另一个故事)。 Sorry I got wrong. Only the instance explicitly mocked become a mock. The others are object of the real classes. I got wrong becaus ...
  • 它绝不可能是ClassA以外的任何东西 ......除了它,在你的测试中。 测试代码是真正的代码,虽然这并不意味着它应该潜入您的生产应用程序,但它确实意味着您需要为所有用例编写所需的灵活性 ,包括测试 。 Mockito通过子类工作: mock(Foo.class)或@Mock Foo mockFoo mockFoo创建的@Mock Foo mockFoo实际上是Mockito创建的代理子类,它覆盖了Foo的每个方法。 从描述中可以看出,Mockito因此不能改变每个 Foo对象的行为,尤其是不能改变new ...
  • 每个方法的Mockito默认实现由RETURNS_DEFAULTS给出,除非另有配置,否则延迟到ReturnsEmptyValues : 每个Mockito模拟的默认答案。 返回原始返回方法的适当原语 返回原始包装类的一致值(例如,int-returning方法返回0,Integer-returns方法返回0) 返回集合返回方法的空集合(适用于最常用的集合类型) 返回toString()方法的mock的描述 如果引用等于则返回零,否则对于Comparable#compareTo(T other)方法返回非零 ...
  • MyController类中的第二行myMethod(String someId, SomeHeaderParams someHeaderParams) : 有一个方法myClientService.getHeaderParams(SomeHeaderParams)的调用:我没有看到该调用的任何模拟配置,所以它应该返回null ,并且当调用buildRequest(String, Map, Map)方法时,它应该重新调用null作为第二个参数。 anyMap()匹配器anyMap() ,这就是为什么它返回默 ...
  • 不幸的是不可能。 Mockito家伙正在使用CGLIB作为字节码引擎,他们使用它的方式不允许对方法(或其他任何事情)进行注释注入,所以不幸的是,Mockito无法实现你想做的事情。 我认为他们的跟踪器中存在一些关于相关事情的错误/增强。 为了克服这一点 - 你可以创造自己的间谍,而不是使用Mockito的间谍吗? 就像创建一个扩展你现在正在监视的类的类,并以某种方式覆盖会导致测试出现问题的东西? 很难给出更具体的建议,无需看到课程本身。 Unfortunately not possible. Mockito ...
  • 一种方法: public class YourTest { @Order public static class YourAnnotatedClass extends YourClass {} @Mock YourAnnotatedClass yourAnnotatedClass; // ... } 这将确保您的类型在其层次结构中具有所需的注释。 Mockito的覆盖基于Proxy / CGLIB / ByteBuddy,并不完全在任何适当的类上进行注释或在反射中使用。 实际上,可能有一些 ...
  • 你不要覆盖你的模拟 mockCrypto = CryptoManager.getCrypto(); 经测试 @Test(expected=RuntimeException.class) public void testdecrpyMcpDataExceptions() throws Exception { Crypto mockCrypto = mock(Crypto.class); doThrow(new RuntimeException()).when(moc ...
  • 你的代码不是测试友好的,特别是这两行测试非常糟糕: EntityDao entityDao = new EntityDao(); UserDao userDao = new UserDao(); 此代码应从此方法移至Factory或使用类似Spring(依赖注入)的类似注入。 仅靠Mockito无法测试这样的代码。 你的方法应该只做一件事,创建Daos是其他工作。 我会推荐你两部来自GoogleTechTalks的电影: 如何编写干净,可测试的代码 清洁代码会谈 - 不要寻找东西! Your code i ...
  • @ kerseyd27, 从您的测试名称testThatObjectsAreNullifiedInOnDestroy看来,您希望验证在演示者被销毁时,您的演示者是否释放了注入的mFooBar对象。 首先,直接回答你的问题: 与我实例化运行测试的对象相比,我的测试类中的模拟对象如何处理引用? 我会让这些答案( 链接1 , 链接2 )说明一切,但解释它与您的问题有何关系。 模拟对象在Test类中实例化,并通过值传递到FooPresenter 。 FooPresenter.mFooBar是FooPresenter ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)